Save FileStream Function and Convert FileStream To String
$30-100 USD
Em Andamento
Publicado há aproximadamente 14 anos
$30-100 USD
Pago na entrega
On deliverables; I have the source code for the project that was started. What I need are 2 routines completed. The first function is called SaveFile. What needs to save to the path specified the Stream. Another routine is a function called ConvertStreamToString. The purpose of this one is I have processes sometimes where I have the stream but it needs to be converted to a String to run functions on it.
The sample uses the path C:\[login to view URL]
Whatever file extension that is used when recreating the sample needs to be used for the paths for saving (to prove it works). (for example if using .gif; then instead of C:\[login to view URL]; will be C:\[login to view URL] plus C:\[login to view URL] instead of C:\[login to view URL] and C:\[login to view URL] instead of C:\[login to view URL]).
If everything is fine; then when running the code; the 3 new files should be exactly the same as the source file. The purpose of the sample instead of just using FileCopy is the data is being uploaded to a server. Both approaches are needed (String representing file and FileStream).
## Deliverables
The code I have is here. I have to post it here. Because I am using visual studio 2010 RC edition and I assume that whatever works should be fine for Visual Studio 2008.
Module Module1
Sub Main()
Dim OldPath As String
OldPath = "C:\[login to view URL]"
Dim FileString As String = ""
Dim FileStream As [login to view URL]
Dim ResultsString As String = ""
FileString = GetFileString(OldPath)
SaveFile("C:\[login to view URL]", FileString)
FileStream = GetFileStream(OldPath)
SaveFile("C:\[login to view URL]", FileStream)
ResultsString = ConvertStreamToString(FileStream)
SaveFile("C:\[login to view URL]", ResultsString)
End Sub
Private Function FixBase64ForImage(ByVal str_Image As String) As String
'*** Need to clean up the text in case it got corrupted travelling in an XML file
Dim sbText As New [login to view URL](str_Image, [login to view URL])
[login to view URL]("\r\n", [login to view URL])
[login to view URL](" ", [login to view URL])
Return [login to view URL]()
End Function
Private Function GetFileString(ByVal Path As String) As String
Dim byte_Array() As Byte
byte_Array = [login to view URL](Path)
Return [login to view URL](byte_Array)
End Function
Private Function GetFileStream(ByVal Path As String) As [login to view URL]
Return New [login to view URL](Path, [login to view URL])
End Function
Private Function ConvertStreamToString(ByVal Stream As [login to view URL]) As String
'needs to be able to convert the stream to a string (because there are processes where it needs to be a string to work with
End Function
Private Sub SaveFile(ByVal Path As String, ByVal Stream As [login to view URL])
'needs to be able to save the stream to the given path
End Sub
Private Sub SaveFile(ByVal Path As String, ByVal Data As String)
If [login to view URL](Path) = True Then
[login to view URL](Path)
End If
Dim byte_Array() As Byte
byte_Array = [login to view URL](FixBase64ForImage(Data))
[login to view URL](Path, byte_Array, False)
End Sub
End Module
Needs the source code only. Must work on buyers environment.
## Platform
Windows (all versions).