Hi there,
I have a question regarding file delete, for this I use the File.Delete() commend . as a parameter for this I send the file path. Which is
“C:\\Documents and Settings\\awaduge\\My Documents\\Visual Studio 2008\\Projects\\Admin Application\\Admin Application\\Details\\P110082010112121\\Report\\Technical Sheet"
And Technical Sheet is the file name. the file can be in txt,execl, pdf any format.
How can I delete the file Technical Sheet in the folder Report.
When I add the command File.Delete() with the path as above, nothing happens
thanxxxxxx

Generally you should be getting either a result of the file being deleted (assuming your directories are correct), an exception (in the event that your path is incorrect) or, in the event that the file does not exist, no exception is thrown.

Referenced from msdn.microsoft.com using Google.

Hope this helps :)

Generally you should be getting either a result of the file being deleted (assuming your directories are correct), an exception (in the event that your path is incorrect) or, in the event that the file does not exist, no exception is thrown.

Referenced from msdn.microsoft.com using Google.

Hope this helps :)

hey, i don't get any exception or anything, the problem is for the file name Technical Report i didn't specify the file extension because i don't know the file extension that is in the folder???????????

do i have to add the file extension to delete a file??????????

Member Avatar for nssltd

I am pretty sure you must add an extension otherwise the application would you think you were talking about a folder but forgot to add the file. i'll look into a post a reply soon but that is what i think, Remember when you do this you dont need to use a windows/mac/ubuntu/linux file you could make up a custom extension like i usually do. You could use extensions such as .XTXT. But now you have a file the application will know what to delete, ill upload a project for you to look at soon

Hope it helps

NSSLTD

msdn.microsoft.com indicates that the path needs to include: "The name of the file to be deleted. Wildcard characters are not supported."

Of course, if you'd read the link I posted instead of focusing all of your energy on typing ?'s into your posts you might have seen that :twisted:

Basically when using file.Delete() you must specify the absolute path to the file (unless the file is local to the working directory of your application) and the full filename of the file. If you are receiving no error message it is likely due to the fact that "the file does not exist" as indicated in my previous post (likely as a result of your not providing an extension for your filename).

If there are multiple possible file extensions for the file you are attempting to delete then perhaps you might want to look into a file.GetFiles() usage to determine the existance and full name of the file you are attempting to delete before attempting to delete it.

Member Avatar for nssltd

Yeah i agree with lusiphur, he was also very informative in his post, i can understand what he's saying. But as you know any problems post them back on his thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.