title: Access to the path is denied in C# Visual Express 2010
body: <p>I'm using Visual C# Express 10. I'm trying to create, open and write to a .avi file from another .avi file. I'm using Aforge dlls for y project. The following code was programmed in a button click.</p>
  
  <pre><code>OpenFileDialog toy = new OpenFileDialog();
  
              toy.Filter = "AVI files (*.avi)|*.avi|All files (*.*)|*.*";
              toy.Title = "Open an AVI file";
              toy.ShowDialog();
              string wish = toy.FileName;
              VideoFileReader reader = new VideoFileReader();
              VideoFileWriter writer = new VideoFileWriter();
              string fileName = @"C:\test.avi";
              FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate);
  </code></pre>
  
  <p>I'm getting error in above line</p>
  
  <pre><code>            // open video file
              reader.Open(wish);
              for (int i = 0; i &lt; 100; i++)
              {
                  Bitmap videoFrame = reader.ReadVideoFrame();
                  int w = videoFrame.Width;
                  int h = videoFrame.Height;
                  writer.Open(@"C:\test.avi",w, h);
                  videoFrame.Save(i + ".bmp");
                  // dispose the frame when it is no longer required
                  //videoFrame.Dispose();
              }
              reader.Close();
  </code></pre>
  
  <p>The error I receive is "Access to the path 'C:\test.avi' is denied".
  I have tried a few solutions in StackOverflow which included changing permissions of C drive and using environmental folders. Please advise me on this.</p>
  
  <p>EDIT:
  Sorry for the delay. I cant write the log file as well. I'm trying to upload a pic</p>
  
  <p>EDIT 2:
  This is the exception. I got it from textbox and just typed it out. I replaced my name with xxxx though.</p>
  
  <pre><code>System.UnauthorizedAccessException: Access to the path 'C:\test.avi' is denied.
  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, Boolean checkHost)
  at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
  FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean
  bFromProxy)
  at System.IO.FileStream..ctor(String path, FileMode mode)
  at VideoFramesTest.Form1.OpenAndSave() in
  C:\Users\XXXX\documents\visual studio
  2010\projects\VideoFramestest\VideoFramestest\Form1.cs:line42
  </code></pre>