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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:42:44+00:00 2026-06-08T04:42:44+00:00

I have a file upload control in my asp.net (c#) website, which is used

  • 0

I have a file upload control in my asp.net (c#) website, which is used to upload csv files with data to be inserted into the database, my problem is that, I was not able to get the actual path of the uploaded file

It always gave me: C:\inetput\projectfolder\csvname.csv
where it should have been similar to: C:\Documents and settings\Pcname\Desktop\csvname.csv

but by going through the various post of file upload, i came to know that file need to be saved on the server first,

using Fileupload1.Saveas(savepath);

which is mandatory to save the file in a previously specified location, where this not actually required. (since it will increase the overhead of again deleting the file).

then what I do is as below:

bool result = true;
strm = FileUpload1.PostedFile.InputStream;

reader2 = new System.IO.StreamReader(strm);

// **** new ****

FileInfo fileinfo = new FileInfo(FileUpload1.PostedFile.FileName);


string savePath = "c:\\"; // example "c:\\temp\\uploads\\"; could be any path

string fileName = fileinfo.Name;
string strFilePath = savePath.ToString();


savePath += fileName;

FileUpload1.SaveAs(savePath);

string strSql = "SELECT * FROM [" + fileinfo.Name + "]";

string strCSVConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePath + ";" + "Extended Properties='text;HDR=NO;'";

// load the data from CSV to DataTable 

OleDbDataAdapter oleda = new OleDbDataAdapter(strSql, strCSVConnString);

DataTable dtbCSV = new DataTable();

oleda.Fill(dtbCSV);

if (dtbCSV.Columns.Count != 2)
{
    result = false;
}

because I want to count the number of columns in the file, I’m using the oledb reader.
which needs a file to be queried.

Is it possible to Query a stream? I dont want to save the file, instead just read it without saving.

  • 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-08T04:42:46+00:00Added an answer on June 8, 2026 at 4:42 am

    Unfortunately you cannot use OLEDB against a stream.

    In situations where it is mandatory to use OLEDB I’ve managed to write an IDisposable wrapper that would provide a temporary file from a stream and manage deletion.

    You could however go for an alternate approach to reading the contents, without saving it, such as parsing the file yourself directly from a stream. I would recommend this instead of the wrapper since you avoid file access restriction problems as well as the overhead of file access.

    Here’s an SO with several different approaches.

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

Sidebar

Related Questions

I have used file upload control of asp.net but I am getting empty string
I want to upload 30GB with asp.net file upload control, i have heard that
I have a asp.net vb.net app, with a upload file control, when i upload
I have an ASP.NET MVC web page that has a file upload control. Under
I have a web form that include Asp.net File Upload Control to Upload a
I have an asp.net application where the users can upload files to our database.
I have a web page where i have an ASP.NET file upload control to
Is there a file upload control for ASP.Net which performs a client-side checksum calculation
I am working on an ASP.net project and I have a file upload control.
I was trying to upload the database of my ASP.NET website. On the local

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.