Unblock File from within .net 4 c#
It's stored in the :Zone.Identifier
stream (more < c:\theapp.exe:Zone.Identifier
) you need to use the native IO routines to manipulate them, here is a managed wrapper.
How to remove programmatically the security protection of a copied file in network directory?
Open this file for write yourfile.exe:Zone.Identifier
and close it, so it gets emptyed.
Is there a way to automate unblocking of a .net assembly
This is a flag that is added to the assembly by the Explorer. I think the easiest way to overcome this problem would be to store your assembly as a compressed zip archive on the network location and then unzip it to the local path where you need it.
this file is blocked because it came from another computer - ajax permission issue
The NTFS file system attache to this file a flag as unsafe. You can use one utility from Sysinternals called Streams to remove this flag. You can download the Streams from:
http://technet.microsoft.com/en-us/sysinternals/bb897440.aspx
Then using the Process class you can run the streams -d <file.xml>
command to remove this flag, after you have get the file. How to run it:
Process runcommd = new Process();
runcommd.StartInfo.FileName = "streams";
runcommd.StartInfo.Arguments = " -d \"fullpath\\file.xml\"";
runcommd.StartInfo.UseShellExecute = false;
runcommd.StartInfo.CreateNoWindow = false;
runcommd.StartInfo.RedirectStandardError = true;
runcommd.StartInfo.RedirectStandardOutput = true;
runcommd.StartInfo.RedirectStandardInput = true;
// now run it
runcommd.Start();
// be sure that we end
runcommd.StandardInput.Flush();
runcommd.StandardInput.Close();
The Streams are from MS site, so its official and credible source, and its just a utility that remove this flag from the file. I think that you can do your job.
Related:
https://superuser.com/questions/38476/this-file-came-from-another-computer-how-can-i-unblock-all-the-files-in-a
http://www.k9ivb.net/files/This%20file%20came%20from%20another%20computer%20and%20might%20be%20blocked.pdf
How can I unblock a file using C#?
You can try opening a FileStream with FileShare.ReadWrite flag. E.g:
new FileStream("myFile.dat", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
The gives more than one process the ability to write to the file.
Related Topics
C# Optional Parameters on Overridden Methods
Compare Version Numbers Without Using Split Function
Is Async Await Keyword Equivalent to a Continuewith Lambda
Suppressing "Is Never Used" and "Is Never Assigned To" Warnings in C#
How to Get the File Size in C#
Make Listview.Scrollintoview Scroll the Item into the Center of the Listview (C#)
How to Get and Set the Window Position of Another Application in C#
What Are the Downsides to Turning Off Proxycreationenabled for Ctp5 of Ef Code First
Excel to Datatable Using Epplus - Excel Locked for Editing
Linq to Entities Only Supports Casting Edm Primitive or Enumeration Types with Ientity Interface
Compare Equality Between Two Objects in Nunit
Simplest Way to Do a Fire and Forget Method in C# 4.0
Using Case/Switch and Gettype to Determine the Object
Facebook/ Twitter with Dotnetopenauth
Why Does Resharper Want to Use 'Var' for Everything