I get an error :
Access to the path 'C:\Program Files (x86)\MetaTrader FIX\experts\indicators\Awesome.ex4' is denied./n at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.File.Create(String path)
at Iron_loader.Program.Main(String[] args) in C:\Users\Damian\Documents\Visual Studio 2010\Projects\Iron loader\Iron loader\Program.cs:line 55
when I run my exe file from \bin\Debug .
I don’t know why is that. In destination directory there is no such file, so I think that there is a problem with security, ecause when I run my program from VS as admin everything goes ok.
I’m trying to upload files to folder of other program(not mine).
How can I copy that file?
File.Create(newPath);
File.Copy(pathOfFileFromMyDebugDirectory, newPath);
…see Edit below
I believe that part of the problem is that the ‘process’ has not yet released the file handle. Try this:
As soon as you hit the closing brace in the using block, the base stream
Dispose()method is called and all resources – including the process’ file handle – should be released.Edit
Are you getting the exception at the ‘File.Create’ call? I misread the error you gave. If you are getting the exception at the Create() method, then you need to make sure you have the right to write to the path.
I believe, that when you rectify the rights issue, you may get an exception that the handle is in use by another process. If so, use my suggestion above to fix.