473,378 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Exception Details: System.IO.DirectoryNotFoundException:

Hi,

Not sure if my question belongs in an ASP.NET or MSSQL forum..

I have an ASP.NET webpage built in VS2010 with an Input field with the functionality to browse to a network directory, select a text file, read content and upload the data to an MSSQL database table. Nothing fancy.

I am programming on a client, debugging, and running the website locally and the process works like a charm. When I publish the site to a webserver, browse to it and do exactly the same thing the following server error it thrown:
__________________________________________________ _______________________________________

Server Error in '/' Application.
Could not find a part of the path 'Z:\Data\AQVD_ReadReport20101108020000.txt'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'Z:\Data\AQVD_ReadReport20101108020000.txt'.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[DirectoryNotFoundException: Could not find a part of the path 'Z:\Data\AQVD_ReadReport20101108020000.txt'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +224
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) +1142
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) +82
System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) +87
System.IO.StreamReader..ctor(String path) +30
MeteringInnovation._Default1.UploadFileButton_Clic k(Object sender, EventArgs e) in Z:\Visual Studio Projects\MeteringInnovation\MeteringInnovation\Arq iva\Default.aspx.vb:8
System.Web.UI.HtmlControls.HtmlInputButton.OnServe rClick(EventArgs e) +118
System.Web.UI.HtmlControls.HtmlInputButton.RaisePo stBackEvent(String eventArgument) +112
System.Web.UI.HtmlControls.HtmlInputButton.System. Web.UI.IPostBackEventHandler.RaisePostBackEvent(St ring eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
__________________________________________________ _______________________________________

VB code:

Imports System.IO
Imports System.Data.SqlClient

Public Class _Default1
Inherits System.Web.UI.Page

Private Sub UploadFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UploadFile.ServerClick
Dim sr As New StreamReader(File1.Value)
Dim strLine As String = ""

Do Until sr.EndOfStream
strLine = sr.ReadLine
saveData(strLine)
Loop

UploadResultLabel.Text = "Data imported"

End Sub

Private Sub saveData(ByVal data As String)
Dim sb As System.Text.StringBuilder
Dim dc As New SqlConnection("Data Source=SERVER;Initial Catalog=DATABASE;Integrated Security=True")
Dim cm As New SqlCommand()
Dim dataValues() As String = data.Split(",")
Dim radioUnit As Long = dataValues(4)
Dim Meter As String = dataValues(5)
Dim dateTimeStamp As String = ""
Dim reading As Integer = 0
cm.Connection = dc
dc.Open()
For i As Integer = 14 To dataValues.Length - 1 Step 3
sb = New System.Text.StringBuilder
dateTimeStamp = dataValues(i)
reading = dataValues(i + 2)
sb.Append("Insert into dbo.TABLE Table (COL1, COL2, COL3, COL4) Values(")
sb.Append(COL1 & ",")
sb.Append("'" & COL2 & "',")
sb.Append("'" & COL3 & "',")
sb.Append(COL4 & ")")

cm.CommandText = sb.ToString()
cm.ExecuteNonQuery()
Next

dc.Close()

End Sub


This is in a domain Intranet environment, no firewalls etc. As I said, I am not sure if the problem is programming, network permissions or SQLdb permissions. Because of the nature of the error I'm swayed to think (as some forum posts suggest) ASPNET permissions are required on the sources directory. However, as these are networked I cannot check this option. IIS application pools are not a strong point for me, the site is in the default pool running v4.0 Integrated with NetworkService identity.

All pointers welcome.

Thanks
Feb 16 '11 #1
3 4418
vanc
211 Expert 100+
G'day mate,

The error indicates clearly that it cannot find the path on the server which is running fine locally on your PC.

Is there Z drive on the server and the text file is available?

It also may relate to user access privileges on the server, if you can access the server you can check the security settings in the selected folder and files.

Cheers.
Feb 23 '11 #2
Thanks vanc. I've since found out the StreamReader input paramters were incorrectly defined so when published to a webserver the full directory path wasn't retrieved. My revised code to solved this is below.

But with this code, only the last row of the text file dataset is stored in strLine, not all rows. I'm sure if this possibly has something to do with the StreamReader definition "(FileUpload1.PostedFile.InputStream)". The loop worked in my previous code so what what am I missing?


Expand|Select|Wrap|Line Numbers
  1.       If (TextFile.HasFile) Then
  2.  
  3.             ' get file path and name            
  4.             Dim sr As New StreamReader(TextFile.PostedFile.InputStream)
  5.  
  6.             ' declares new empty strLine
  7.             Dim strLine As String = ""
  8.  
  9.             Do Until sr.EndOfStream
  10.                 strLine = sr.ReadLine
  11.                 saveData(strLine)
  12.             Loop
  13.  
  14.             UploadStatusLabel.Text = "Your file uploaded successfully"
  15.         Else
  16.             UploadStatusLabel.Text = "You did not specify a file to upload"
  17.         End If
  18.  
  19.     End Sub
Many thanks!
Feb 23 '11 #3
vanc
211 Expert 100+
Your loop is to save data by calling saveData function and the loop will end with the last line of the stream, that's why the strLine will keep the last row of the text file, I think you may want to put all texts into strLine and call saveData function?

Expand|Select|Wrap|Line Numbers
  1. Do Until sr.EndOfStream
  2.    strLine += sr.ReadLine 'C#
  3. Loop
  4.    saveData(strLine)
  5.  
This loop ends with the whole text in strLine variable. Is this what you after?

Cheers.
Feb 24 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mita | last post by:
I Am trying to post my form on to a second page, but it keeps coming with a, error: Exception Details: System.Web.HttpException: The View State is invalid for this page and might be corrupted. ...
2
by: Bill Nguyen | last post by:
I got this error emssage trying to run an ASP.NET application on my Win2003/IIS6.0 server: Exception Details: System.UnauthorizedAccessException: Access to the path...
4
by: Ram | last post by:
I am running a test web site on my own Win2k professional computer. I have a VB6 COM component (running on COM+) on a seperate application runnint as "Server". When running an ASP.NET page calling...
6
by: Tony | last post by:
Dear All, When I run an example program on the http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid1.src&file=VB\datagrid1.aspx&font=3 ...
0
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves...
0
by: masago | last post by:
Hi....how are you ?? they can help me to solve this problem ?? Access to the path = "c:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET = Files\reports\06639073\bbab30a7" is...
1
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF...
2
by: itsvineeth209 | last post by:
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more...
4
by: minhtran | last post by:
Hi All I create web page as ASP.NET . The program runs on localhost no problem,but when we upload on server has an error as : An unhandled exception occurred during the execution of the current web...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.