I was told that I had no permission to delete the file, so I was depressed.
If (file. exists ("D: // phone // headimages //" + this.txt number. Text. Trim () + ". jpg "))
{
File. Delete ("D: // phone // headimages //" + this.txt number. Text. Trim () + ". jpg ");
}
When the file exists, it cannot be deleted. Instead, it tells me that another process is using the file or something?
In your previous code, there should be a part of the file to be written without closing the file, or the operation is interrupted abnormally. The simple method is to close the development environment and re-enter the environment, you can delete it normally.
Core code for writing files:
Filestream FS = new filestream (file path, filemode. Create );
// Obtain the byte array
Byte [] DATA = new utf8encoding (). getbytes (string );
// Start writing
FS. Write (data, 0, Data. Length );
// Clear the buffer and close the stream
FS. Flush ();
FS. Close ();
Pasting
Song Dynasty
When you delete files, the system prompts that you do not have the permission to delete the files. This is just one of the prompts that you cannot delete files. It is very easy to solve this problem, you only need to grant the file to be deleted to the Current Account.
1
How to grant User Permissions
Locate the file you want to delete, right-click the file, select properties, and switch to "security. Click the "advanced" button in the lower-right corner, switch to the "owner" item, and click the "edit" button below. It is best to change the file owner to the current user name, such as administrators, and select the "Replace sub-container and object owner" option, next, just click OK. Then, try again to delete the file and you will not be prompted that the permission is insufficient.
2
Here we will share with you that the file is in use when you delete the file.
You can disable the exeplorer.exe process and then delete it after starting the process. This is equivalent to the logout effect.
3
You can only delete it in security mode.
This method has almost no files to delete.
Download the Windows XP system (xpghost.com ).
When deleting a file, the system prompts you that you are not authorized to delete the file. What should I do?