|
-
Apr 2nd, 2002, 12:40 PM
#1
Thread Starter
Frenzied Member
moving a file
how do i move a file (text document) that the user selects to a designated folder?
-
Apr 2nd, 2002, 12:56 PM
#2
VB Code:
FileCopy "c:\mytext.txt", "c:\my documents\mytext.txt"
Kill "c:\mytext.txt"
-
Apr 2nd, 2002, 12:57 PM
#3
Junior Member
well
you can do that with drag drop
code
---------------------------
Private Sub File1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then File1.Drag
End Sub
...
I hope this helps you
-
Apr 2nd, 2002, 12:57 PM
#4
Thread Starter
Frenzied Member
great. Is it possible to just say to move it to the same folder as the exe? because i wont always know exactly where it is
-
Apr 2nd, 2002, 01:01 PM
#5
Hyperactive Member
VB Code:
FileCopy App.Path & "\mytext.txt", "c:\my documents\mytext.txt"
Kill App.Path & "\mytext.txt"
is that what you wanted??
p|-|34|2 /\/\3 f0|2 | $p34k 1337 
My TSS quote of the day: "If your haveing a bad day, just press the restart button."
-
Apr 2nd, 2002, 01:01 PM
#6
"The same folder as the exe" doesn't mean anything to FileCopy. You will need to know exactly where the file is to be moved.
If you don't know, before the move, then you need to get that path. You can do that, with this:
VB Code:
Private Declare Function SearchTreeForFile Lib "imagehlp" (ByVal RootPath As String, ByVal InputPathName As String, ByVal OutputPathBuffer As String) As Long
Private Const MAX_PATH = 260
Private Sub Command1_Click()
Dim tempStr As String, Ret As Long
'create a buffer string
tempStr = String(MAX_PATH, 0)
'returns 1 when successfull, 0 when failed
Ret = SearchTreeForFile("c:\", "MyExe.exe", tempStr)
If Ret <> 0 Then
'use this for your FileCopy command
MsgBox "Located file at " + Left$(tempStr, InStr(1, tempStr, Chr$(0)) - 1)
Else
MsgBox "File not found!"
End If
End Sub
-
Apr 2nd, 2002, 02:09 PM
#7
Thread Starter
Frenzied Member
why cant i just specify a folder to move to, why do i have to give the full path?
-
Apr 2nd, 2002, 02:12 PM
#8
Because your program won't know where the folder is. You have to tell it.
-
Apr 2nd, 2002, 02:14 PM
#9
Thread Starter
Frenzied Member
i meant just the folder. for example c:\My Documents\ instead of c:\My Documents\myfile.txt
-
Apr 2nd, 2002, 02:17 PM
#10
Ohh...that because thats what FileCopy is looking for. Full path and file name. If you only specify a path, you will get an error.
Why?
I don't know. It does seem silly, but thats the way it is.
-
Apr 2nd, 2002, 02:18 PM
#11
Thread Starter
Frenzied Member
-
Apr 2nd, 2002, 02:22 PM
#12
Thread Starter
Frenzied Member
well ok then if i have the path:
c:\my documents\myfile.txt
how can i remove the first part and end up with
myfile.txt
-
Apr 2nd, 2002, 02:27 PM
#13
VB Code:
Dim sParts() As String
sParts = Split("C:\MyWorld\MyStyle\WhoCares\Junk.txt", "\")
'sParts(UBound(sParts)) contains File name 'Junk.txt'
'to check
MsgBox sParts(UBound(sParts))
-
Apr 2nd, 2002, 02:36 PM
#14
Thread Starter
Frenzied Member
thanks for all your help hack. it is appreciated.
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
|