When deleting a file, the system prompts you that you are not authorized to delete the file. What should I do?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.