|
-
Jun 28th, 2000, 12:10 AM
#1
Thread Starter
Lively Member
Okay I have added the code and taken out the one line. It works great for the first file, but the second file gives me error number 53 File not Found. What am I doing wrong??
Using VB6 Still Pluging away
-
Jun 28th, 2000, 12:25 AM
#2
Hyperactive Member
Then the file isn't there. or it can't be moved. Is it a read-only file?
-
Jun 28th, 2000, 12:30 AM
#3
Hyperactive Member
I'm sorry, I didn't mean read-only. Is the file an exe or dll which is being executed?
-
Jun 28th, 2000, 01:04 AM
#4
Thread Starter
Lively Member
No all accounts as far as I know. I'm going to check to make sure that it has been closed, but I'm positive that it has.
Using VB6 Still Pluging away
-
Jun 28th, 2000, 01:05 AM
#5
Fanatic Member
Code:
Sub f_Move(str_Source As String, str_Destin As String)
Dim lng_FileNumber As Long
lng_FileNumber = FreeFile
Open str_Destin & "Move.Bat" For Output As #lng_FileNumber
Print #lng_FileNumber, "Move " & Chr(34) & str_Source & "\*.*" & Chr(34) & " " & Chr(34) & str_Destin & Chr(34)
Close #lng_FileNumber
DoEvents
Call Shell(str_Destin & "Move.Bat", vbHide)
Kill str_Destin & "Move.Bat"
End Sub
The only downside to this code is that, it won't move files that already exist in the destination directory. Can you kill the destination directory before you move the files? If not, there is another trick.
This is how you use the function.
Call f_Move("C:\Source\", "C:\Destination\")
Chemically Formulated As:
Dr. Nitro
-
Jun 28th, 2000, 01:12 AM
#6
Thread Starter
Lively Member
Without useing Nitro code I'm now getting error 58 file already exits, but it is not in the destination directory
Using VB6 Still Pluging away
-
Jun 28th, 2000, 07:27 AM
#7
_______
..I move my files using this...
'you can move files with this..no need to delete or anything else
'to check it out build a new app and add a listbox List1 and
'a command button Command1
'copy this code into the code section and run...
'Once the file is moved it is gone from location 1 and in location 2
'Check if directory exists
'-----------------------------------
Public Function DirExists(ByVal sDirName As String) As Boolean
Dim sDir As String
On Error Resume Next
DirExists = False
sDir = Dir$(sDirName, vbDirectory)
If (Len(sDir) > 0) And (Err = 0) Then
DirExists = True
End If
End Function
Private Sub Command1_Click()
' make sure user has selected a file from the list
If File1.ListIndex >= 0 Then
Dim strFilePath As String
Dim strFileName As String
strFilePath = File1.Path & "\" & File1.FileName
strFileName = File1.FileName
End If
'check for directory..if not in existance then create the
'directory and then move the file
Dim SourcePath, Destpath As String
SourcePath = strFilePath
Destpath = "c:\MyNewFolder\"
If DirExists(Destpath) Then 'does the file exist
Dim sFile$
sFile = Destpath & strFileName
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
'if there is a file in the new dir with file name exit sub
If fs.fileexists(sFile$) = True Then
Dim sUser
sUser = "Sorry, that file exist already." & vbCrLf
sUser = sUser & vbCrLf
sUser = sUser & "No need to duplicate...use delete function."
MsgBox sUser
Exit Sub
End If
Name SourcePath As Destpath & "/" & strFileName
Set fs = Nothing
Else
MkDir ("C:\MyNewFolder")
'FileCopy SourcePath, DestPath
Name SourcePath As Destpath & strFileName
End If
File1.Refresh
End Sub
Private Sub Form_Load()
File1.Path = "c:\my documents"
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 28th, 2000, 06:59 PM
#8
Thread Starter
Lively Member
HeSaidJoe,
I'm trying your code and I'm getting the following error, Compile Error, Can't find project or library. This is happening on File1.path. What am I missing??
Using VB6 Still Pluging away
-
Jun 28th, 2000, 07:11 PM
#9
transcendental analytic
aburke, youre probably moving a either readonly file, running exe or a file opened by an application in read access. In other words you cannot move the file if you don't remove the readonly attribute, if it's readonly or unlock your harddrive if it's opened or running
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 28th, 2000, 07:20 PM
#10
Thread Starter
Lively Member
None of the files are read only. Yes I have to open them in Acrobat, but I open them to insert one file into the other one, and then close them before I ever try to move them. The really big kicker is that it all worked under Windows NT and now will not work under Windows 98. The people I'm desgining this for all use 98. If anyone wants the code to see what I'm doing I'll gladly send it to you. I have almost had enough on working on this part, but of course the rest of the project depends on this part working, sort of.
Using VB6 Still Pluging away
-
Jun 28th, 2000, 07:52 PM
#11
transcendental analytic
Does it give you any errors when you move it manually a) in explorer b) in dos?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 28th, 2000, 07:59 PM
#12
Thread Starter
Lively Member
No to either one. I have also gone in and checked all of the persmissions/attributes and have removed any if there where any there.
Using VB6 Still Pluging away
-
Jun 28th, 2000, 08:02 PM
#13
_______
...reason is....
i do believe the reason would be that you
don't have a file list box called File1
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 28th, 2000, 08:06 PM
#14
Thread Starter
Lively Member
Yes that would be it, I just have a list box, oops.
Using VB6 Still Pluging away
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|