Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-02-2006, 04:17 AM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2005
Posts: 28
Default How to handle files in VB?


I want to use DOS commands like as COPY, MD, DEL, MOVE and so on in Visual Basic.
How can I do that?
__________________
Naikosen
naikosen is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 08-02-2006, 06:24 AM   #2 (permalink)
Wise Old Owl
 
siriusb's Avatar
 
Join Date: May 2005
Location: Chennai, India, Asia, the Earth, the Solar system, the Milky Way, the Local group, this Universe.
Posts: 1,171
Default

You can do those things and more to a file/folder/drive easily using the File System Object model. To enable that, go Project->References and check "Microsoft Scripting Runtime". Now you can do any thing with the files and folders. Example,
Code:
Dim fso As New FileSystemObject

fso.CopyFile "c:\syslog.txt", "d:\", True
fso.CreateFolder "d:\new folder"
fso.MoveFile "c:\rubbish.txt", "d:\"
fso.DeleteFile "d:\rubbish.txt", True

Set fso = Nothing
__________________
http://myxp.blogspot.com
-----------------------
Winchester 3200+ @2,500MHz
LeadTek 7900GT VOLT MODDED @ 680 core, 1800 mem
2x1GB Transcend DDR400 @ DDR454 2.5,3,3,5,1T
siriusb is offline  
Old 13-02-2006, 05:33 AM   #3 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2005
Posts: 28
Default

Thank you very much 'siriusb'

I'am gonna give it a try.

Thank you again.
__________________
Naikosen
naikosen is offline  
Old 14-02-2006, 02:40 PM   #4 (permalink)
Right Off the Assembly Line
 
Join Date: May 2004
Posts: 16
Default

naikosen, to execute ANY DOS commands within VisualBasic code, try the following :

varX = Shell("Command.com /c <place the full DOS command here>", vbMinimizedFocus)

e.g.

varX = Shell("Command.com /c Type D:\Reports\Bill.Txt", vbMinimizedFocus)
Eager_Beever is offline  
Old 14-02-2006, 02:42 PM   #5 (permalink)
Right Off the Assembly Line
 
Join Date: May 2004
Posts: 16
Default

naikosen, to execute ANY DOS commands within VisualBasic code, try the following :

varX = Shell("Command.com /c <place the full DOS command here>", vbMinimizedFocus)

e.g.

varX = Shell("Command.com /c Type D:\Reports\Bill.Txt", vbMinimizedFocus)
Eager_Beever is offline  
Old 14-02-2006, 02:42 PM   #6 (permalink)
In The Zone
 
Join Date: Oct 2004
Location: Visnagar
Posts: 227
Default

u can use shell also
vinaypatel is offline  
Old 15-02-2006, 04:47 AM   #7 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2005
Posts: 28
Default

Is there any way to delete a locked file?
What is the best way to search a file?
Rar file can delete even a locked file before extraction.
__________________
Naikosen
naikosen is offline  
Old 15-02-2006, 12:26 PM   #8 (permalink)
Wise Old Owl
 
siriusb's Avatar
 
Join Date: May 2005
Location: Chennai, India, Asia, the Earth, the Solar system, the Milky Way, the Local group, this Universe.
Posts: 1,171
Default

Quote:
Is there any way to delete a locked file?
I've never tried deleting a locked file. You will want to run your program before windows starts to delete such files. But there's a VC++ example for a forcedel at codeguru.com that claims to do it. Maybe you can port it VB.

Quote:
What is the best way to search a file?
Like I said, use one of these methods:
1. Use the SearchPath API
2. Use the FindFirstFile with the FindNextFile APIs
3. Use the built-in Dir() function
4. Use the Drivelistbox, Dirlistbox and Filelistbox controls to walk through each directory in every drive to find the file.
5. Use the FSO drives,folders and files collection to do the same in (4).

The best way would be to use any of the API methods as they are much faster.
__________________
http://myxp.blogspot.com
-----------------------
Winchester 3200+ @2,500MHz
LeadTek 7900GT VOLT MODDED @ 680 core, 1800 mem
2x1GB Transcend DDR400 @ DDR454 2.5,3,3,5,1T
siriusb is offline  
Old 15-02-2006, 07:32 PM   #9 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2005
Posts: 28
Default

Thank you very much again "siriusb"
__________________
Naikosen
naikosen is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by topgear
- by Charan

Advertisement




All times are GMT +5.5. The time now is 07:03 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2