[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

save file as type "Text Document -MS-DOS Format" from a dataset in C#

Posted on 2007-07-23
7
Medium Priority
?
1,611 Views
Last Modified: 2013-12-17
I am trying to write a Dataset to a Text file using FileStream in C#.
When I try to open the file it opens it as file type: Text Documents (.txt) and encoding Unicode.
Is there any way I can specify to save the file as type Text Document -MS-DOS Format with fixed length?

Thanks in advance for ur help.
0
Comment
Question by:DotNetBuddha
7 Comments
 
LVL 8

Expert Comment

by:sabeesh
ID: 19549270
what happen if u have save it as .doc file
0
 
LVL 1

Author Comment

by:DotNetBuddha
ID: 19549632
i need to have it with .txt extension.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19549662
Use DataSet.WriteXml, and give it any name you want.

Bob
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 1

Author Comment

by:DotNetBuddha
ID: 19549885
I can save it as .txt file from DataSet. But i want it to have filetype "Text Document MS-DOS" (.txt) rather than "Text Document" (.txt). Is there anywhere I can specify the filetype along with filename,mode and access?
even if I use DataSet.WriteXml it's saving the file as regular "Text document" .txt file.
When the client opens the file he wants to see it as type: Text Document MS-DOS" (.txt)
Is there anywhere i can attach my screenshot of what i am talking about?
thanks,
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19549932
If DataSet.WriteXml doesn't fit your requirement, then you need to create your own DataSet writer, and format the file the way that you need.

Bob
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1500 total points
ID: 19550556
It being that the XML spec says that XML is written in unicode, I am not surprised that it doesn't offer you a way to convert it to ASCII ... this could however be done quite easy. A simple way of dealing with this would be to pass a StringWriter then write the string out to your file using a StreamWriter that has been created with the encoding set to Encoding.ASCII.

http://msdn2.microsoft.com/en-us/library/3aadshsx.aspx

I wouldn't recommend this though as it is non-compliant and will cause issues with globalization etc

Cheers,

Greg
0
 
LVL 14

Expert Comment

by:chinu1310
ID: 19552632
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question