PC Review


Reply
Thread Tools Rate Thread

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

 
 
Guoqi Zheng
Guest
Posts: n/a
 
      17th Aug 2004
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



 
Reply With Quote
 
 
 
 
Tom Shelton
Guest
Posts: n/a
 
      17th Aug 2004
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]
 
Reply With Quote
 
Guoqi Zheng
Guest
Posts: n/a
 
      17th Aug 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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]



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CreateDirectory() - Could not find a part of the path "D:\". =?Utf-8?B?Q2xpbnRvbiBGcmFua2xhbmQ=?= Microsoft ASP .NET 9 6th Jun 2005 06:52 PM
DirectoryNotFoundException - Could not find a part of the path "D:\". Tom Vogel Microsoft ASP .NET 5 30th Aug 2004 04:05 AM
Re: Noob question: "Could not find a part of the path" Phil Winstanley [Microsoft MVP ASP.NET] Microsoft ASP .NET 0 15th Jun 2004 09:27 AM
Noob question: "Could not find a part of the path" haylow Microsoft ASP .NET 0 15th Jun 2004 09:10 AM
"Could not find a part of the path" error dsh Microsoft ASP .NET 0 15th Jan 2004 09:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:57 AM.