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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:05:00+00:00 2026-06-09T15:05:00+00:00

Following code transfer file successfully, but does not print in lable that it has

  • 0

Following code transfer file successfully, but does not print in lable that it has been transferred. Although other checks were shown perfectly. Is there any logical eror in it?

        if (txtFile1.HasFile)
        {
        var folderfile1 = Server.MapPath("~/files/Operations_Support/IMSI");
        string flFile1 = txtFile1.PostedFile.FileName;
        string saveflFile1 = folderfile1 + "\\" + System.IO.Path.GetFileName(flFile1);

        FileInfo Finfo = new FileInfo(txtFile1.PostedFile.FileName);
        if (Finfo.Extension.ToLower() == ".txt")
        {
            if (txtFile1.PostedFile.ContentLength < 1024)
            {
                //if (!File.Exists(folderfile1))
                if (Directory.GetFiles(folderfile1).Length == 0)
                {
                    txtFile1.SaveAs(saveflFile1);
                    //lbFile1.Visible = true;
                    lbFile1.Text = "Upload status: IMSI file transfered successfully";
                }

                else
                {
                    lbFile1.Text = "Upload status: Please wait until the previous file is processed";
                }

            }
            else
                lbFile1.Text = "Upload status: The file has to be less than 1 kb!";
        }
        else
            lbFile1.Text = "Upload status: Only Text files are accepted!";
    }
    else
    {
        lbFile1.Visible = true;
        lbFile1.Text = "Upload status: Please select file";
    }
  • 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-09T15:05:01+00:00Added an answer on June 9, 2026 at 3:05 pm

    Use File.Exists like this:

    var folderfile4 = Server.MapPath("~/files/Path");
    string saveflFile4 = folderfile4 + "\\" + System.IO.Path.GetFileName(flFile4);
    if(!File.Exists(saveflFile4))
        txtFile4.SaveAs(saveflFile4);
    else
        txtError.Text = "File exists";
    

    Server.MapPath returns a physical path on the server, so you can use File.Exists to check if the file is present or not.

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

Sidebar

Related Questions

I have the following code header(Content-Description: File Transfer); header('Content-Type: audio/mp3'); header(Content-Disposition: attachment; filename= .
I am thinking of using following code, but I want to transfer hundreds of
I'm trying to use the following code to create a zip file from a
Im using the following code to present a file for download. The file saves
I am using this code... Server.Transfer(/Student/StudentControlPanel.aspx?username= + username); And getting the following Exception: InvalidOperationException
I have following PHP code $filename = 'a56.flv'; $file = C:/xampp/htdocs/site/flv/a56.flv; header(Content-Type: application/force-download); header('Content-Type:
I use the following code to create and send the csv file to a
I am using the following code segment to download a file to the SD
I have the following code that creates and downloads an xml formatted page. My
Following code produces a nested array as a result for keys containing three items:

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.