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 8160829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:21:51+00:00 2026-06-06T18:21:51+00:00

I am creating a tempfile using C#. public partial class frmResults : Form {

  • 0

I am creating a tempfile using C#.

public partial class frmResults : Form
{
    public static string caseFile = "";

    private void frmResults_Load(object sender, EventArgs e)
    {
        caseFile = CreateTempFiles();
        FileInfo file = new FileInfo(caseFile + ".rpt");

        if (file.Exists)
        {
            try
            {   
                if (fil.Length < 64000000)
                {
                    richTabular.LoadFile(caseFile + ".rpt", RichTextBoxStreamType.PlainText);
                } 
            }
            catch (IOException io)
            {
                MessageBox.Show(io.GetType().Name);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static string CreateTempFiles()
        {
            string sPath;
            caseFile = Path.GetTempFileName();

            sPath = Path.GetTempPath();
            string workDir = sPath + "\\work\\";
            // create work directory
            if (!Directory.Exists(workDir))
            {
                Directory.CreateDirectory(workDir);
            }
            // create temp file name
            int i = 0;
            string tmpfileprefix = workDir + "Rdp";
            string tmpfilename = "";
            do
            {
                i++;
                tmpfilename = tmpfileprefix + i.ToString("D6");
            } while (File.Exists(tmpfilename + ".rpt"));

            caseFile = tmpfilename;
            return caseFile;
        }
    }
}

Error:fil.Length = 'fil.Length' threw an exception of type 'System.IO.FileNotFoundException'
Could not find file 'C:\Users\sc\AppData\Local\Temp\\work\Rdp000001.rpt'.

Also, if (fil.Exists) returns false.

  • 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-06T18:21:54+00:00Added an answer on June 6, 2026 at 6:21 pm

    The error message couldn’t be more clear:

    Error:fil.Length = ‘fil.Length’ threw an exception of type ‘System.IO.FileNotFoundException’ Could not find file ‘C:\Users\sc\AppData\Local\Temp\work\Rdp000001.rpt’.

    So… it’s not a valid File object, yet you call a method (Length) which requires it to be, so an exception was thrown. Your file doesn’t exist.

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

Sidebar

Related Questions

I found some code on here for creating temporary directories in Java. public static
I am creating a logger in java by executing the following code: private static
Creating My Windows Form Application and using ADO.Net as Data Access layer and SQL
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
Creating a simple RPG game, first time using XNA. Trying to get my character
Error creating bean with name 'sessionFactory' defined in class path resource [ApplicationContext.xml]: Invocation of
I'm creating a Tempfile like this Tempfile.new(myfile.txt) This creates a file like this TempDir/myfile.txt20120210-1696-yd53si
Creating the closure is easy but using it is confusing for me. Here is
I'm creating a collage of thumbnails using Ruby 1.9.3. The thumbnails are being loaded
////Creating Object var Obj; // init Object Obj= {}; What's the difference between these

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.