473,394 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Delete files

49
Can somebody help me out with a code snippet to cut files from one folder to another in vb.. i.e cut all from src to dest and delete it from src ..


Thanks,
Nag.
Sep 19 '08 #1
5 1318
debasisdas
8,127 Expert 4TB
you need to use FILESYSTEMOBJECT for this .
Sep 19 '08 #2
lee123
556 512MB
here is a ay to do this i have been working on this and it works. remeber when using the "FILESYSTEMOBJECT" you have to use the "Microsoft Scripting Runtime" in the in "Project: under Reference"

and way try this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDelete_Click()
  2. Dim response As String
  3. Dim fso As New FileSystemObject, fldr As Folder, s As String
  4. If cmdDelete Then
  5.     response = MsgBox("Are You Sure you want To Delete This Folder, The Content of the Files In It Will Be Deleted As Well?", vbYesNo + vbQuestion, "Response")
  6.     fso.DeleteFolder (the name of folder goes here), True
  7.     MsgBox "Folder Has Been Deleted!", , "Deleted Folder is Complete"
  8.     txtDeleteFolder.Text = ""
  9. End If
  10. End Sub
in this code i used a Textbox to enter in a folder i wanted to delete, then i asked a question if they wanted to delete this folder. but you can try other things out.

lee123
Sep 19 '08 #3
nagmvs
49
here is a ay to do this i have been working on this and it works. remeber when using the "FILESYSTEMOBJECT" you have to use the "Microsoft Scripting Runtime" in the in "Project: under Reference"

and way try this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdDelete_Click()
  2. Dim response As String
  3. Dim fso As New FileSystemObject, fldr As Folder, s As String
  4. If cmdDelete Then
  5.     response = MsgBox("Are You Sure you want To Delete This Folder, The Content of the Files In It Will Be Deleted As Well?", vbYesNo + vbQuestion, "Response")
  6.     fso.DeleteFolder (the name of folder goes here), True
  7.     MsgBox "Folder Has Been Deleted!", , "Deleted Folder is Complete"
  8.     txtDeleteFolder.Text = ""
  9. End If
  10. End Sub
in this code i used a Textbox to enter in a folder i wanted to delete, then i asked a question if they wanted to delete this folder. but you can try other things out.

lee123


Hello lee,

Ur code is 100% working,Great.Thanks for sending me this code.Sir actually i don't want to delete total folder i want to delete the files on that folder only.So how can i achieve that.i try some methods using ur code but i am not successfull.So please help me to delete the files on that folder only.
Otherwise i just copy or cut the files on that folder and move those files to some other system.(is it possible ?) how can i do this ? any ideas ?
Sir i have one doubt.after compiling ur code in vb,the specified folder is deleted successfully. but i can't see that folder in Recycle Bin.so where is it going in my system.In my system which place i can find that deleted folder.

Thanks,
Nagesh.
Sep 20 '08 #4
nagmvs
49
you need to use FILESYSTEMOBJECT for this .

Oh that's fne.thanks.
Sep 20 '08 #5
debasisdas
8,127 Expert 4TB
try to use this

Expand|Select|Wrap|Line Numbers
  1. Set fso = Server.CreateObject("Scripting.FileSystemObject") 
  2. Set fileObject = fso.GetFile(source filename)
  3. response.Write(targetfilename)
  4. fso.moveFile sourcefilename, TargetFileName 
  5.  
you need to use

FSO.FileExists(File)
to check if the file exists before moving the file.
better to use common dialog control to select the file
Sep 20 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jobs | last post by:
Hello All, I want to delete all files in a directory. I am making a backup copy of all files in the directories say c:\abc by reading and writing to a file. After making a backup copy I want to...
3
by: Scott_Tuttle | last post by:
I'm trying to delete files with strange characters in the names but csharp doesnt seem to be able to see them at all. Solution??
2
by: Keith Smith | last post by:
I have noticed that when I uninstall my app it doesn't delete the Program Files / MyApp folder if there are "new" files in it that weren't there before. It deletes all files except the "new" ones....
6
by: Neo The One | last post by:
On my development machine, I often delete all folders/files under C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files. That has not caused me any trouble til now. So now we have...
8
by: milkyway | last post by:
Hello, I have created many sample web sites for testing and now I would like to do some cleanup. When doing searches, it seemed that there were a good number of approaches to removing a web...
9
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3)...
2
by: createdbyx | last post by:
I am trying to make a file sync utillity to sync files between my laptop and my desktop pc. On my desktop machine (xp pro sp2) I have shared my "Visual Studio Projects" folder using windows simple...
5
by: wo20051223 | last post by:
Deleting some files with C# fails with "Access to the path 'X' is denied". I have files copied from a CD that I burned (and not locked by a process) and a text file that I created in Windows...
2
by: nospam | last post by:
I am writing this app in .net 2003 since all machines don't have 2.0 framework. I am trying to delete old profiles, but I am getting access denied or file in use errors. A lot of these files I am...
2
by: Thomas Bauer | last post by:
Hello, Call DeleteFiles bgW_DeleteFilesProcess = new DeleteFiles(); bgW_DeleteFilesProcess.RunAsync( folder, 5, "*.txt", new RunWorkerCompletedEventHandler( RunWorkerCompleted_DeleteFiles_TXT )...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.