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.
5 1318
you need to use FILESYSTEMOBJECT for this .
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: -
Private Sub cmdDelete_Click()
-
Dim response As String
-
Dim fso As New FileSystemObject, fldr As Folder, s As String
-
If cmdDelete Then
-
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")
-
fso.DeleteFolder (the name of folder goes here), True
-
MsgBox "Folder Has Been Deleted!", , "Deleted Folder is Complete"
-
txtDeleteFolder.Text = ""
-
End If
-
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
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: -
Private Sub cmdDelete_Click()
-
Dim response As String
-
Dim fso As New FileSystemObject, fldr As Folder, s As String
-
If cmdDelete Then
-
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")
-
fso.DeleteFolder (the name of folder goes here), True
-
MsgBox "Folder Has Been Deleted!", , "Deleted Folder is Complete"
-
txtDeleteFolder.Text = ""
-
End If
-
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.
you need to use FILESYSTEMOBJECT for this .
Oh that's fne.thanks.
try to use this -
Set fso = Server.CreateObject("Scripting.FileSystemObject")
-
Set fileObject = fso.GetFile(source filename)
-
response.Write(targetfilename)
-
fso.moveFile sourcefilename, TargetFileName
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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??
|
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....
|
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...
|
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...
|
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)...
|
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...
|
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...
|
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...
|
by: Thomas Bauer |
last post by:
Hello,
Call
DeleteFiles bgW_DeleteFilesProcess = new DeleteFiles();
bgW_DeleteFilesProcess.RunAsync( folder, 5, "*.txt", new
RunWorkerCompletedEventHandler( RunWorkerCompleted_DeleteFiles_TXT )...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
| |