Results 1 to 8 of 8

Thread: [RESOLVED] Problem moving File using vb 6

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Resolved [RESOLVED] Problem moving File using vb 6

    I have manually moved the file
    I am trying to move a text file( Customer.dat) to a new location and cannot get get the LOF(miFilenumber) to stop displaying 0
    Public Sub LoadMyFile
    Open cusfile For Random As #miFilenumber Len = Len(gCustomer)
    Debug.Print Len(cusfile) ' displays 94
    Debug.Print Len(gCustomer) ' displays 547
    Debug.Print LOF(miFilenumber) ' displays 0 should display 48230
    path to old file location C:\Program Files (x86)\Microsoft Visual Studio\VB15\addressbook\AppFolder\Customer.dat
    path to new file location: C:\Users\Public\Documents\Personal\Contacts\Customer.dat
    what am i doing wrong ?
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Problem moving File using vb 6

    You are opening cusfile so cusfile must have a valid path and filename contained in it. If it does not you will not get an error because opening For Random creates a new file of the invalid filename which will have a LOF of 0

    So, make sure cusfile contains a valid path and filename which I think should be:

    C:\Program Files (x86)\Microsoft Visual Studio\VB15\addressbook\AppFolder\Customer.dat


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  3. #3

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Problem moving File using vb 6

    Quote Originally Posted by jmsrickland View Post
    You are opening cusfile so cusfile must have a valid path and filename contained in it. If it does not you will not get an error because opening For Random creates a new file of the invalid filename which will have a LOF of 0

    So, make sure cusfile contains a valid path and filename which I think should be:

    C:\Program Files (x86)\Microsoft Visual Studio\VB15\addressbook\AppFolder\Customer.dat
    thanks for your reply
    The path/Filename you listed is the old path that works fine
    i have moved the file here
    C:\Users\Public\Documents\Personal\Contacts\Customer.dat
    I have double checked the path/name to no avail
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Problem moving File using vb 6

    Not sure what you are saying

    I only helped you with the LOF problem. As far as moving the file I have no idea as I do not see how you are trying to move it

    Don't understand--->I have double checked the path/name to no avail

    Why are you opening a file if all you want is to move it

    Also you say Debug.Print Len(cusfile) ' displays 94

    but that length is not the length of either of your two paths and it should be the length of the path\filename of the file you are opening
    Last edited by jmsrickland; May 22nd, 2016 at 03:56 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  5. #5
    gibra
    Guest

    Re: Problem moving File using vb 6

    Try to open the file as Binary, not as Random.

  6. #6

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Problem moving File using vb 6

    Quote Originally Posted by jmsrickland View Post
    You are opening cusfile so cusfile must have a valid path and filename contained in it. If it does not you will not get an error because opening For Random creates a new file of the invalid filename which will have a LOF of 0

    So, make sure cusfile contains a valid path and filename which I think should be:

    C:\Program Files (x86)\Microsoft Visual Studio\VB15\addressbook\AppFolder\Customer.dat
    Found the problem The file was 0 length, don't know how did a copy and paste
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Problem moving File using vb 6

    So the file was already 0 to begin with. OK, that takes care of your Open file problem now what about your move problem? Copy/Paste is not the way to go; you need to do a physical move using code.

    I've included two zip files. Try one or the other or both as I don't know which one actually works but one of them does
    Attached Files Attached Files
    Last edited by jmsrickland; May 23rd, 2016 at 12:09 AM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  8. #8

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Problem moving File using vb 6

    Quote Originally Posted by jmsrickland View Post
    So the file was already 0 to begin with. OK, that takes care of your Open file problem now what about your move problem? Copy/Paste is not the way to go; you need to do a physical move using code.

    I've included two zip files. Try one or the other or both as I don't know which one actually works but one of them does
    thanks
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width