[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 ?
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
Re: Problem moving File using vb 6
Quote:
Originally Posted by
jmsrickland
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
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
Re: Problem moving File using vb 6
Try to open the file as Binary, not as Random.
Re: Problem moving File using vb 6
Quote:
Originally Posted by
jmsrickland
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
2 Attachment(s)
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
Re: Problem moving File using vb 6
Quote:
Originally Posted by
jmsrickland
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