|
-
Dec 5th, 2000, 06:45 AM
#1
Thread Starter
Fanatic Member
Can anyone give me a code that will copy a file to the windows directory without giving me an ERROR! Thanx..
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Dec 5th, 2000, 06:57 AM
#2
Lively Member
Copy File
Ere you go.
Dim FileSysObject As Object
Set FileSysObject = CreateObject("Scripting.FileSystemObject")
FileSysObject.CopyFile "F:\Filename.txt", "c:\WINNT\"
Mad in Manchester.....
Ian Frawley
Software Engineer
E-mail [email protected]
BEING IN THERAPY
And yet, having therapy is very much like making love to a beautiful woman. You... get on the couch, string 'em along with some half-lies and evasions, probe some deep dark holes, and then hand over all your money.
-
Dec 5th, 2000, 07:04 AM
#3
_______
<?>
Code:
Private Sub Command1_Click()
Dim SourcePath As String, DestPath As String
SourcePath = "c:\my documents\myFile.txt"
DestPath = "c:\Winnt\myFile.txt"
FileCopy SourcePath, DestPath
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
-
Dec 5th, 2000, 07:07 AM
#4
Lively Member
HeSaidJoe
HeSaidJoe's way is the proper way to do it. I am spending so much time working with ASP's and VBScript that I tend to use the File System Object alot. Still works though...
Ian Frawley
Software Engineer
E-mail [email protected]
BEING IN THERAPY
And yet, having therapy is very much like making love to a beautiful woman. You... get on the couch, string 'em along with some half-lies and evasions, probe some deep dark holes, and then hand over all your money.
-
Dec 5th, 2000, 07:12 AM
#5
Thread Starter
Fanatic Member
but..
I want it to figure out the windows directory because for one, I change the windows directory name!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Dec 5th, 2000, 07:14 AM
#6
_______
<?>
Code:
'find the windows directory path
'usefull in shell commands if you know something
'is in the windows directory
'example..instead of shell c:\windows\notepad.ext
'you could use shell windir$ & /notepad.exe
'if windows was stored in E:/Windows then you wouldn't get an error
'if you used shell c:/windosw\notepad.exe, it couldn't be found '(error)
'
Option Explicit
Private Declare Function GetWindowsDirectory _
Lib "kernel32" Alias "GetWindowsDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long
'
Private Sub Form_Load()
'
Dim strFindWinDir$, WinDir$
'
WinDir$ = Space(144)
strFindWinDir$ = GetWindowsDirectory(WinDir$, 144)
WinDir$ = Trim(WinDir$)
'
MsgBox "The Windows Directory Path is: " & WinDir$
'
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
-
Dec 5th, 2000, 07:16 AM
#7
_______
<?>
Ianf
Your way is fine..the only diff is you need an extra dll when you export your application to others. If you are using the FSO for multiple instances of different situtations, then it's quite ok.
All ways that work are ok, they are just job specific for a certain set of circumstances.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Dec 5th, 2000, 07:25 AM
#8
Lively Member
Just to finish off
My way
Dim WshShell As Object
Const pfad = "%windir%\"
Set WshShell = CreateObject ("WScript.Shell")
msgbox WshShell.ExpandEnvironmentStrings(pfad)
Ian Frawley
Software Engineer
E-mail [email protected]
BEING IN THERAPY
And yet, having therapy is very much like making love to a beautiful woman. You... get on the couch, string 'em along with some half-lies and evasions, probe some deep dark holes, and then hand over all your money.
-
Dec 5th, 2000, 07:34 AM
#9
Thread Starter
Fanatic Member
Your coding doesn't work because it doesn't let me type anyting after C:\WinMe
If I do this
MSGBOX GetWinDir & "\Lss.exe"
it will open a message boc with C:\WinMe
it doesn't show the rest of my message
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Dec 5th, 2000, 07:39 AM
#10
Thread Starter
Fanatic Member
nice code lanf! Thanx for the short and good code! I've been trying this for days!
Visual Basic 6.0
Visual C++ 5
Delphi 5

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
|