Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2004, 12:34 PM
Friend of Wrox
 
Join Date: Jun 2003
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

 
Old August 9th, 2004, 04:02 PM
Friend of Wrox
 
Join Date: Aug 2003
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
 
Old August 9th, 2004, 05:24 PM
Friend of Wrox
 
Join Date: Jun 2003
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

 
Old August 10th, 2004, 02:18 AM
Authorized User
 
Join Date: Aug 2003
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.
 
Old August 10th, 2004, 09:18 AM
Friend of Wrox
 
Join Date: Jun 2003
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

 
Old August 10th, 2004, 11:18 AM
Friend of Wrox
 
Join Date: Aug 2003
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





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 10:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.