Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 9th, 2004, 12:34 PM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default Delete A File

I am writting an application where I need to list the contents of a directory in a server and have the user delete file or files the user selected. The user will not be able to see this server so I will have to map the path from VB and display the contents of the directory.

I am not familiar on how I can use the dialog box if this is even what I need to use. Please help me.

Thanks,
Judy

Reply With Quote
  #2 (permalink)  
Old August 9th, 2004, 04:02 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Judy,

What do you need? Do you need help displaying the dialog box? Do you need help mapping the path? I am guessing that mapped drives are out, so you will need to use a UNC path through a network. The folder they are seeing will need to allow them rights to see and delete. Please correct my assumption if I am wrong? Can you give us some more details about your project?

Yehuda
Reply With Quote
  #3 (permalink)  
Old August 9th, 2004, 05:24 PM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Sorry about not being detailed on what I am asking for help. I just basically do not know where to start.

Yes you are right I will need to use a UNC path through a network. The folder they are seeing will need to allow them rights to see and delete. How do you even start to code the logic behind it? Listing the contents of the directory? Sending a Delete File command is there even an event I can use to do this?

I will list the contents of the folder in a listbox. User will highlight files to be deleted then hit a command button which will issue the delete file command. If you can just help me with what VB properties or functions I can use to this that would be great.

Thanks,
Judy

Reply With Quote
  #4 (permalink)  
Old August 10th, 2004, 02:18 AM
Authorized User
 
Join Date: Aug 2003
Location: , , Belgium.
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

To list the content of a folder you can use the 'Dir' command in VB or you can have a look at the 'FileSystemObject'.

To delete a file you simply use the 'Kill' command with the full path.

Hope it gives you a start

Greetz

Tom.
Reply With Quote
  #5 (permalink)  
Old August 10th, 2004, 09:18 AM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Thanks Tom this is very helpful. I just need directions on how to go about this project, what, how and when to use it. I will start from here and see what I can find out about the filesystemobjects.

Is there a site I can go to look at sample codes for this?

Thanks for both your help.

Judy

Reply With Quote
  #6 (permalink)  
Old August 10th, 2004, 11:18 AM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think the File.delete from the system object is a slightly more effective delete than the Kill command (at least I have had more luck with it). Here is a good resource for the FileSystem object :
http://msdn.microsoft.com/library/de...stemobject.asp
Below is an example on using Dir

' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
   ' Ignore the current directory and the encompassing directory.
   If MyName <> "." And MyName <> ".." Then
      ' Use bitwise comparison to make sure MyName is a directory.
      If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
         Debug.Print MyName ' Display entry only if it
      End If ' it represents a directory.
   End If
   MyName = Dir ' Get next entry.
Loop
Reply With Quote
Reply


Thread Tools
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to delete file System.IO.Delete error maricar C# 13 March 14th, 2014 06:50 AM
How can I delete a file doctorsom Beginning PHP 2 July 28th, 2005 02:29 PM
File Delete qazi_nomi Classic ASP Basics 1 May 17th, 2005 06:54 PM
Delete a file on the server zaeem Classic ASP Basics 0 April 20th, 2005 10:10 PM
JSP file upload and delete file pandjie JSP Basics 0 January 29th, 2005 09:49 PM



All times are GMT -4. The time now is 04:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.