Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9081205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:15:36+00:00 2026-06-16T20:15:36+00:00

I am using FileStream to create a file with given Length . OpenFileDialog to

  • 0

I am using FileStream to create a file with givenLength.OpenFileDialog to open a file and FolderBrowserDialog to get the Location. Now the problem is when I choose Location on D:\ or E:\ drive it successfully creates the file. But when I choose C:\ drive it gives an Exception like UnauthorizedAccessException was unhandled.
C:\file.mp4 is denied.
When I choose desktop as destination it gives no Exception and Does not create the file. I’m using this code

    private void createFile()
    {
        long size = fileInfo.Length;
        string name = file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1, (file.FileName.Length - (file.FileName.LastIndexOf('\\') + 1)));
        string filename = "" + location.SelectedPath + name;

        FileStream outFile = new FileStream(filename, FileMode.Create);
        outFile.SetLength(size);
        outFile.Close();
    }

My UAC is disabled and Also I am an Administrator user.I’m using windows 8 pro. Can anybody explain what can be the solution ? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:15:38+00:00Added an answer on June 16, 2026 at 8:15 pm

    Permission issue. In case of Vista/Windows 7/8, C:\ drive is considered as system, and you’ll need elevated privileges for your process in order to create files directly under it. Try running your process or Visual Studio as Administrator, and it should work.

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
So I am using the FileStream inside XmlReader using (XmlReader reader = XmlReader.Create(new FileStream(archivePath,
I want to write one single bit to a binary file. using (FileStream fileStream
I get an Out of Memory Exception when using Http.Put of a large file.
I have a requirement where the file should be split using a given character.
In .NET, a file can be written to the file system using: FileStream fs
I'm a newbie on c# programming. I have a problem when I'm using FileStream
I have been trying to mock out a using with a file stream but
Using the Redis info command, I am able to get all the stats of
I have written the following piece of code that reads through a given xml-file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.