MemoryStream to File

Lec11
Member Posts: 91
Hello,
I am trying to read some data from a memory stream and write it to a file using DotNet variables in Nav 2013. I am not a DotNet specialist but I found some code on the web and tried to adapt it:
But I am getting the following error:
From what I see, the WriteTo method support a stream parameter. Isn't it the same with FileStream?
Can anybody throw an advice on this? Or maybe guide me to the proper way of doing it?
Regards!
I am trying to read some data from a memory stream and write it to a file using DotNet variables in Nav 2013. I am not a DotNet specialist but I found some code on the web and tried to adapt it:
Filepath := FileMgmt.ClientTempFileName('txt');
FileMode := FileMode.Create();
FileAccess := FileAccess.Write();
FileStr := FileStr.FileStream(FilePath,FileMode,FileAccess);
MemoryStream.WriteTo(FileStr);
FileStr.Close();
MemoryStream.Flush();
MemoryStream.Close();
But I am getting the following error:
Microsoft Dynamics NAV
A call to System.Net.ConnectStream.WriteTo failed with this message: The type of one or more arguments does not match the method's parameter type.
OK
From what I see, the WriteTo method support a stream parameter. Isn't it the same with FileStream?
Can anybody throw an advice on this? Or maybe guide me to the proper way of doing it?
Regards!
0
Comments
-
Hi,
Take a look at this link
http://www.mibuso.com/forum/viewtopic.php?f=7&t=58425&hilit=ftp
The code uses extensively streams, so you will definitely find differtn example for what you need.
I hope this helps.
Thanks.0 -
try this
string memString = "Memory test string !!";
// convert string to stream
byte[] buffer = Encoding.ASCII.GetBytes(memString);
MemoryStream ms = new MemoryStream(buffer);
//write to file
FileStream file = new FileStream("d:\\file.txt", FileMode.Create, FileAccess.Write);
ms.WriteTo(file);
Source....MemoryStream to File
Dov0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions