By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

Could not find a part of the path "C:\temp\".

P: n/a
Dear sir,

I am trying to save a binary data by below script, however,it always give me
an error of "Could not find a part of the path "C:\temp\". "

Any idea what I did wrong here?

Public Sub SaveAs(ByVal strPath As String)

If strPath.EndsWith("\") = False Then
strPath += "\"
End If

Dim binaryData() As Byte
binaryData = System.Convert.FromBase64String(m_Filestring)

'Write out the decoded data.
Dim outFile As System.IO.FileStream
Dim OutFileName As String = strPath + m_FileName
outFile = New System.IO.FileStream(OutFileName,
System.IO.FileMode.Create, System.IO.FileAccess.Write)
outFile.Write(binaryData, 0, binaryData.Length - 1)
outFile.Close()

End Sub

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 17 Aug 2004 01:49:55 +0200, Guoqi Zheng wrote:
Dear sir,

I am trying to save a binary data by below script, however,it always give me
an error of "Could not find a part of the path "C:\temp\". "

Any idea what I did wrong here?

Public Sub SaveAs(ByVal strPath As String)

If strPath.EndsWith("\") = False Then
strPath += "\"
End If

Dim binaryData() As Byte
binaryData = System.Convert.FromBase64String(m_Filestring)

'Write out the decoded data.
Dim outFile As System.IO.FileStream
Dim OutFileName As String = strPath + m_FileName
outFile = New System.IO.FileStream(OutFileName,
System.IO.FileMode.Create, System.IO.FileAccess.Write)
outFile.Write(binaryData, 0, binaryData.Length - 1)
outFile.Close()

End Sub


Imports System
Imports System.IO

Public Sub SaveAs (ByVal strPath As String)
Dim outFile As FileStream

Try
' you don't need the if test for the path - .net
' already has a class that handles this :)
Dim outFileName As String = Path.Combine (strPath, m_FileName)
Dim binaryData() As Byte = _
Convert.FromBase64String (m_FileString)

outFile = New FileStream _
(outFileName, FileMode.Create, FileAccess.Write)
outFile.Write (binaryData, 0, binaryData.Length)

' insert catch here if you wish to process exceptions,
' other wise, just make sure you do the necessary clean up
' in the finally and the exception will go up to the caller
Finally
If Not outFile Is Nothing Then
outFile.Close()
End If
End Try
End Sub

You may have to show the calling code to get a final answer though...
Since, more then likely the path being passed in is invalid.

--
Tom Shelton [MVP]
Nov 21 '05 #2

P: n/a
Thanks for your reply. I have used some of your code.

problem solved, because m_FileName is nothing.

--
Kind regards

Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com

"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> wrote in message
news:12****************************@40tude.net...
On Tue, 17 Aug 2004 01:49:55 +0200, Guoqi Zheng wrote:
Dear sir,

I am trying to save a binary data by below script, however,it always give me an error of "Could not find a part of the path "C:\temp\". "

Any idea what I did wrong here?

Public Sub SaveAs(ByVal strPath As String)

If strPath.EndsWith("\") = False Then
strPath += "\"
End If

Dim binaryData() As Byte
binaryData = System.Convert.FromBase64String(m_Filestring)

'Write out the decoded data.
Dim outFile As System.IO.FileStream
Dim OutFileName As String = strPath + m_FileName
outFile = New System.IO.FileStream(OutFileName,
System.IO.FileMode.Create, System.IO.FileAccess.Write)
outFile.Write(binaryData, 0, binaryData.Length - 1)
outFile.Close()

End Sub


Imports System
Imports System.IO

Public Sub SaveAs (ByVal strPath As String)
Dim outFile As FileStream

Try
' you don't need the if test for the path - .net
' already has a class that handles this :)
Dim outFileName As String = Path.Combine (strPath, m_FileName)
Dim binaryData() As Byte = _
Convert.FromBase64String (m_FileString)

outFile = New FileStream _
(outFileName, FileMode.Create, FileAccess.Write)
outFile.Write (binaryData, 0, binaryData.Length)

' insert catch here if you wish to process exceptions,
' other wise, just make sure you do the necessary clean up
' in the finally and the exception will go up to the caller
Finally
If Not outFile Is Nothing Then
outFile.Close()
End If
End Try
End Sub

You may have to show the calling code to get a final answer though...
Since, more then likely the path being passed in is invalid.

--
Tom Shelton [MVP]

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.