Delete Files Using VB?
Aug 27, 2009
i wanna be able to check if the file "thisfile.exe" exists, and if it does then delete all the other *.exe files it finds but not deleteing the "thisfile.exe", how would i be able to do that?
edit - im using vb 2008 express?
View 8 Replies
ADVERTISEMENT
Feb 4, 2010
Can someone point me in the direction for displaying the contents of a folder on the form with a check box, then if someone wants to delete a file then check the box and hit delete. How can I do that?
View 5 Replies
Aug 23, 2011
I have an external hard disk drive for data backup purpose. Now I want to delete all mp3 files in that drive. How do I do it?NOTE: The mp3 files are contained within many nested folders. For example, K:(artist name)(album name)mp3 filesUpdate: I tried using system.io.directory.getallfiles(), but my mp3 files are contained in many many folders. My current approach is not working
View 4 Replies
Oct 12, 2009
The MSDN Express Library 2008 suggests the following example to delete all of the files in a folderFor Each foundFile As String In My.Computer.FileSystem.GetFiles( My.Computer.FileSystem.SpecialDirectories.MyDocuments, FileIO.SearchOption.SearchAllSubDirectories, "*.*")
My.Computer.FileSystem.DeleteFile(foundFile, FileIO.UIOption.AllDialogs,FileIO.RecycleOption.DeletePermanently)NextI would like to adapt this code to delete all the files in a folder of my choosing; for example, all the files in c:msdnimages. But I'm not getting anywhere.Would someone be kind enough to explain how to substitute c:msdnimages for SpecialDirectories.
View 3 Replies
Jan 30, 2010
I am trying to build a program to delete temporary files from my c drive.
View 3 Replies
Jun 26, 2012
I'm writing a little app that I can tell to delete files older than x amount of days.
You select a folder and click go and it does the job but it only does the files within that folder. What I want to do is also delete all the files in all the sub folders. [code]....
View 1 Replies
Dec 15, 2004
I was trying to do something like this (that worked with the Kill method of VB6) System.IO.File.Delete(OrderInfo.ParentFolderPath & "NJ0*.DTA") because there are several files that start with NJ0 and end with .DTA
[Code]...
View 3 Replies
Nov 23, 2009
i want to delete some files but only if they aren't in use. What i did was a try/catch:
Try
My.Computer.FileSystem.DeleteFile(fileInfo.FullName)
Catch ex As Exception
End Try
but it seems that this method is very slow if i try to delete some files over network.
Is there an faster way to delete files? Is it faster to check first if an file is open? If yes, how can i check if an file is open?
View 5 Replies
Feb 18, 2010
In my application,I have some reports which needs to be viewed frequently.After viewing the reports many times by different users, it shows load error.For different systems, many temporary files are created.i need to delete those files in my single system.now i manually deleting all the temporary files in the temp directory and configure the IIS again.then the report loads properly.But we need to delete these temporary files frequently which makes our life dreadful.Only the report files needs to be deleted.How can i delete these temporary files automatically using code? I have used the following code for this.but some files cant be deleted as those files are in use.Do those temporary files in other system can cause load error in our system?
dim temp as string=Environment.GetEnvironmentVariable("TEMP")
dim k as sting()=System.IO.Directory.GetFiles(temp)
dim i as integer[code].....
View 2 Replies
Sep 8, 2011
I need a code to find all files. mp3 on your hard disk with certain tags (eg: Shakira, Pitbull, 50 Cent, etc.). and then delete it.
Try
For Each f In Directory.GetFiles("D:", "*.mp3", SearchOption.AllDirectories)
File.Delete(f)
[code].....
View 15 Replies
Aug 15, 2011
I need a code to find all files. mp3 on your hard disk with certain tags (eg: Shakira, Pitbull, 50 Cent, etc.). and then delete it.
View 2 Replies
Apr 5, 2011
I created a program that allows my users to upload files to an FTP server and make folders. I have one problem. they cant delete the files yet. [url] you want to see the Upload page just enter random credentials). I was wondering if someone can help me make another form that displays files and folders and subfolders, maybe a listbox and when a user highlights something and clicks the delete button it will delete it or the rename button.
View 12 Replies
Aug 19, 2009
What I basicly want is, a program with-Check boxs, user can check what they want to delete.The check box has to "tell" the button what to delete
Checkbox1= Temp
Checkbox2=Firefox History
Checkbox3=Firefox Cookies
[code].....
View 9 Replies
Mar 7, 2009
My app lets you download backup files from the Internet and save them locally.I want the app to be able to automatically delete old backups though. What's the best way to do this?So if I allow the user to store five files named:
backup-03-03-2009.zip
backup-04-03-2009.zip
backup-05-03-2009.zip
[code]....
View 3 Replies
Jan 21, 2009
How can you delete files in use? I am trying to clear the history and delete temporary internet files in my program. However, I get this error when trying to delete the history:
[Code]....
View 8 Replies
Aug 1, 2011
I'm trying to delete all files in a folder which start with a specific user id so if the user id = 00000 then i want to delete file 00000-1.xml & 00000-2.xml & 00000-3.xml and so on.I have this code so far
Dim path as String = Server.MapPath("../myfolder/xml/00000" & something?? & ".xml")
If path <> "" Then
Dim fileInfo As FileInfo = Nothing[code]....
Obviously I have just added the something?? in as i have no idea what to put there?
View 3 Replies
Jun 11, 2012
I'm working out on a function in my program to let it update all the downloaded files by a button, I tried this:
[code]...
But when I try it .. It says that I cannot remove the directory because it already has files inside it.My question is, how can I remove all these files together (Without mentioning each one of them because they're about 100 files) so I can be able to delete the directory?
View 4 Replies
Nov 3, 2010
I'm trying to read a csv file. I'm also try to delete all files in the temp directory on the page load. Everything goes fine the first time, but the second time I get an error saying it couldn't delete the file because it is in use by another process. I'm aware that this process is my vb file, I just can't seem to find what I need to dispose of to get rid of the file lock.
Here is my code
Imports System
Imports System.Web
Imports System.Web.UI.HtmlControls
Imports System.IO
Imports System.Xml
[Code] .....
View 3 Replies
Jul 3, 2010
I wonna delete/create directorys on the FTP server and delete files. i have used my.computer.network.upload/downloadfile but i cant do much more whit that ..
View 5 Replies
Jun 5, 2011
Well i figure that if i do a temp. batch file for a small project heres the batch script. IPAddy would = a number xx.xx also how to execute from a button and run as admin at the same time. @echo off netsh interface ipv4 set address "local Area Connection" static 10.IPAddy.2
View 1 Replies
Feb 20, 2009
My program takes screen shots and saves them but i want to incoorporate a function that allows a user to delete all the images in the file they choose to save them into [code] And its not working the program names each image after the frame that it was taken, ie the first frame is called 1 the second two etc..I want to delete all of the files and the folder that they were saved in but this way doesnt work and is not horribly efficient.filedir is a textbox on the form that the user inputs a save location so thats what i am using to determin files to delete.
View 2 Replies
Feb 8, 2012
I have a basic bit of code which i am using to delete text files within a given directory[code]...
intdays is a variable which determines how many days the files should be retained for.
To test the code i set intdays to 0, assuming that it would delete any files in the directoy. However it doesn't, but creates no errors.
The time "Now" is #2/8/2012 13:59:00 PM# which is greater than 0. But im confused as to why it doesnt then delete the file?
View 2 Replies
Jan 17, 2011
I searched the forum for solving this issue, but couldn't find one. I made an uninstaller which uninstalls certain application. However this application have lots of read-only files and folders and my uninstaller isn't able to remove any of them. So I need a code that would do so. Here's the uninstaller code that I have:
[Code]...
View 5 Replies
Mar 28, 2010
I try to delete my Temporary Internet Files and I do it by using the command "kill()", but I get an error:"No files found matching".What is the problem?
View 14 Replies
Apr 27, 2009
I want to delete some temporary log files in remote system without using UNC share path. If I used UNC share path in my application, the application execution was failed. In order to execute successfully, i want to map remote system in my machine and then application was executed successfully by using UNC share path. So, i dont like to use UNC share path in my application.
View 4 Replies
Jan 17, 2011
I made an uninstaller which uninstalls certain application. However this application have lots of read-only files and folders and my uninstaller isn't able to remove any of them.
Here's the uninstaller code that I have:
Imports System.IO
Dim path As String
Dim tempstring As String
Dim totalbytes As Long
[Code] .....
View 4 Replies
Mar 28, 2010
I try to delete my Temporary Internet Files and I do it by using the command "kill()", but I get an error: "No files found matching".
View 6 Replies
Sep 20, 2010
can FileSystemWatcher prevent the user to delete a file ?
View 3 Replies
Sep 14, 2009
I would like to know how to declare this function, I have seen it used and i have the class SHFileOPStruct and all the components of it, i have then declared a function with the components of the class i am using, and when i try and follow examples of how to use the SHFileOperation function i get an error asking me to name SHFileOperation, how would i name it? Is it not an inbuilt function?
What am i actually trying to do? Delete temperary folders that are created during the running of my program. How can i do this using SHFileOperation
here is my code below:
' Declaration for File Recycling (from modFCOM)
Public Structure SHFILEOPSTRUCT
Dim hwnd As Integer
Dim wFunc As Integer 'operation to be done
[code].....
View 2 Replies
Nov 19, 2009
I want delete all files in a folder, but I get access denied as the file is locked.I use an email function before i'm trying to delete the files, the send email is a built in function of the application:fcMailer.SendMailWithAttachment Process.Company, "email", Subj, "Bo", "e:upload est.xls" i tried to set it to nothing: set fcMailer = nothing and set fcMailer.SendMailWithAttachment = nothing I'm using the below to delete the files
[code]
Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("e:upload*.*"), DeleteReadOnly
[/code]
How do i remove connection holding the file or simply just delete all locked files / or not locked?
View 1 Replies