Re: Could not find a part of the path "C:\temp\".
From: Guoqi Zheng (no_at_sorry.nl)
Date: 08/17/04
- Next message: yxq: "Re: How to get the install date of OS?"
- Previous message: Nikolay Petrov: "Re: Form controls security"
- In reply to: Tom Shelton: "Re: Could not find a part of the path "C:\temp\"."
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 17 Aug 2004 14:11:53 +0200
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" <tom@YOUKNOWTHEDRILLmtogden.com> wrote in message news:12znfslvvn95g.nqr802zgrj84.dlg@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]
- Next message: yxq: "Re: How to get the install date of OS?"
- Previous message: Nikolay Petrov: "Re: Form controls security"
- In reply to: Tom Shelton: "Re: Could not find a part of the path "C:\temp\"."
- Messages sorted by: [ date ] [ thread ]