Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8389849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:49:57+00:00 2026-06-09T18:49:57+00:00

I am using StreamWriter serialization to overwrite to an existing xml file. Below is

  • 0

I am using StreamWriter serialization to overwrite to an existing xml file. Below is my code segment:

using(StreamWriter sw = new StreamWriter("\\hard disk\logs\test.xml"))
{
   this.Serializer.Serialize(sw,this.StateObject);
}

For some reason from time to time I keep getting IOException on the StreamWriter line, it is very general and it does not have inner exception when i tried to debug it.

StreamWriter line actually clear out the content of my test.xml file and make it to become 0 byte but yet it throws exception at the same time. Because of this exception the serialization never took place so I ended up with a 0 byte file. I can use the exception handler to correct this 0 byte but I am more interested in fixing the original issue of why StreamWriter throws exception in the first place.

Have you guys ever seen this behavior before from StreamWriter? I ensure you that the path is valid, and that I verified it has permission and no other process are accessing that file (even if there is I would have seen that error in my stack trace)

I wonder the fact that I’m running on Window CE has anything to do with it? even though MSDN indicates Window CE supports this System.IO library

Edit:

Below is my stacktrace, the CopyData() function is the one that contains my serialization. Looking at the value at the line System.IO.__Error.WinIOError(Int32 errorCode, String str), I see my str value is “\hard disk\logs\test.xml” and the errorCode is 2147483648.

at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.StreamWriter.CreateFile(String path, Boolean append)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path)
at Shs.ScanPanel.CA.DataManager.DataManagercr.CopyData(Object data)
at System.Threading.Timer.ring()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:49:58+00:00Added an answer on June 9, 2026 at 6:49 pm

    2147483648 is an undocumented error. It’s the equaivalent of 0x80000000–which is not a defined value. StreamWriter only really documents IOException will occur if the filename is invalid. If the filename is invalid, then the error is occuring for some undocumented reason.

    I’d recommend trying to use other classes like FileStream or File (File.Create or File.Open) directly to try and reproduce the problem to see if they provide a more detailed error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works: using (StreamWriter stw = new StreamWriter(Server.MapPath(\\xml\\file.xml))) { stw.Write(xmlEncStr); } This creates an
I see this: using (StreamWriter sw = new StreamWriter(file.txt)) { // d0 w0rk s0n
Suppose this C# code: using (MemoryStream stream = new MemoryStream()) { StreamWriter normalWriter =
I have created an XML file using streamWriter.. Now, i want to remove the
Before writing to the file: using (StreamWriter outfile = new StreamWriter(filePath, false, System.Text.Encoding.UTF8)) {
Here is the code I’m using: using (StreamWriter output = new StreamWriter(Path.Combine(masterdestination, Master.txt))) {
I'm using StreamWriter to write log file. And this is the writing log method,
I have an example in C# code, but it is using streamWriter . It
If I read and wrote a binary file using StreamReader and StreamWriter, can the
I’m using the following code to download a file from a remote ftp server:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.