Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Thank you for your fast reply Christian Graus I have vb.net  and here is the exact error what I got and the code what i  have for that line.

 
Server Error in '/docrs' Application.


\\VACOFPC2\CFM$\CFM1\vadocs\rpd\VP001\001\RPD001-0011.TIF
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.FileNotFoundException: \\VACOFPC2\CFM$\CFM1\vadocs\rpd\VP001\001\RPD001-0011.TIF

Source Error:


Line 212:        For Each path As String In docs
Line 213:
Line 214:            Dim img1 As System.Drawing.Image = System.Drawing.Image.FromFile(path)
Line 215:
Line 216:            g.DrawImage(img1, 0, counter * 1100)


Source File: C:\Inetpub\cfm.vaco.va.gov\docrs\search\view_va_docs.aspx.vb    Line: 214

MY code for line 214 looks like this


Protected
Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim id = Request("id")
Dim sqlstr As String
 
sqlstr =
"Select * from v_vadoc where vadoc_memo_id = " & ID
'If impersonateValidUser("vacocfmdocrs", "DVA", "H2$istory") Then
' Dim imgstr As New SqlCommand(sqlstr, New SqlConnection(strConn))
' imgstr.Connection.Open()
' Dim imgDR As SqlDataReader = imgstr.ExecuteReader()
' imgDR.Read()
' img_path = imgDR("va_doc_original")
' 'img_vadoc_id = imgDR("vadoc_id")
Dim docs As ArrayList = GetImageList(id)
'Dim imgHeight As Integer = 0
'Dim imgWidth As Integer = 0
'Dim vLocation As Integer = 0
 
Dim g As System.Drawing.Graphics
Dim newImg As System.Drawing.Bitmap = New System.Drawing.Bitmap(820, docs.Count * 1100)
g = System.Drawing.Graphics.FromImage(newImg)
Dim counter As Integer = 0
For Each path As String In docs
Dim img1 As System.Drawing.Image = System.Drawing.Image.FromFile(path)
g.DrawImage(img1, 0, counter * 1100)
counter = counter + 1
Next
g.Save()
Dim fileName As String = "download_docs_" + id.ToString()
newImg.Save(Server.MapPath(
"../images/") + fileName + ".tif", System.Drawing.Imaging.ImageFormat.Tiff)
Dim img_path As String = Server.MapPath("../images/") + fileName + ".tif"
Dim file As New FileInfo(img_path)
'Dim bufSize As Integer = 1024 * 64
'Dim buf As Byte() = New Byte(bufSize) {}
 
'For Each inputFile As String In docs
' Dim inFile As FileStream = New FileStream(inputFile, FileMode.Open, FileAccess.Read)
' Dim br As BinaryReader = New BinaryReader(inFile)
' Dim MyData As Byte() = New Byte(inFile.Length) {}
' MyData = br.ReadBytes(inFile.Length)
' Dim outFile As FileStream = New FileStream(img_path, FileMode.Append, FileAccess.Write)
' Dim bw As BinaryWriter = New BinaryWriter(outFile)
 
' bw.Write(MyData)
 
' br.Close()
' br = Nothing
' MyData = Nothing
' 'bw.Flush()
' bw.Close()
' outFile.Close()
'outFile.ReadByte(Data, 0, inFile.Length)
'ReadBytes()
'bw.ReadBytes(MyData)
 'Ne
xt
Response.ClearContent()
Response.AddHeader(
"Content-Disposition", "attachment; filename=" + file.Name)
Response.ContentType =
"image/tif"
Response.TransmitFile(file.FullName)
Response.End()
System.IO.File.Delete(Server.MapPath(
"../images/") + fileName + ".tif")
 
'undoImpersonation()
'End If
End Sub

Posted
Updated 27-Nov-09 9:53am
v2

Yes, I have some ideas

1 - use the tag system.  We have no idea what language you're using, I suspect it's a webpage, but it's impossible to tell for sure.

2 - if you get an 'error', post the error, so we can try to help you

3 - if you have specific code that causes the error, post that too.

I'm assuming you want us to help you as soon as we can, this isn't some sort of IQ test where you deliberately make it hard for us to see who passes first ?

 
Share this answer
 
The error is quite simple I guess. Its a FileNotFoundException, so check if the path passed using System.Drawing.Image.FromFile(path) actually exists or not.

Also if using virtual path, use Server.Mappath. ;)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900