XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

Xbox FileStream.BeginWrite NotSupported?

Last post 11/14/2009 7:16 PM by Sonic 4305. 7 replies.
  • 5/19/2009 4:18 PM

    Xbox FileStream.BeginWrite NotSupported?

    I have looked all over the documentation and I can't seem to find any place that indicate that FileStream.BeginWrite should be unsupported by the xbox. However all calls to it throw a NotSupported exception

    byte[] content = new byte[16]; 
     
    StorageContainer container = m_device.OpenContainer("Test"); 
    string filename = Path.Combine(container.Path, "demobinary.sav"); 
     
    FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None, 4096, true); 
     
    bool bTest = stream.IsAsync; 
     
    IAsyncResult asyncResult = stream.BeginWrite(content, 0, content.Length, new AsyncCallback(SaveCallback), null); 
     

    This is some quick test code, the device is valid. The bTest variable is false as it would be on systems that dont support async operations, BeginWrite throws a NotSupportedException which also indicate that it isnt supported.

    So the quetion is can anyone actually confirm that it is unsupported or did I make a error somewhere?

    If it indeed is unsupported I would suggest that the documentation is made more clear about this fact.



  • 5/19/2009 4:23 PM In reply to

    Re: Xbox FileStream.BeginWrite NotSupported?

    They dont list every single method and property on every single class in the main help just at the class level.
    e.g. http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx says supported in XNA but as you found the method isn't.
    [edit: and as I ALWAYS forget - you have to look in the overload help NOT the method help http://msdn.microsoft.com/en-us/library/t7e3td2c.aspx where you can see XNA framework not listed]

    However exceptions are noted in the XNA help topic here http://msdn.microsoft.com/en-us/library/bb203915.aspx where BeginWrite isn't listed.

    Yes its a pain to have to check 2 lists.
    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 5/19/2009 4:25 PM In reply to

    Re: Xbox FileStream.BeginWrite NotSupported?

    It is not supported on the compact framework, which is what the Xbox uses. The documentation at the bottom of the MSDN page for FileStream.BeginWrite lists the frameworks that support the method, and the compact framework is (correctly) not listed.
  • 5/19/2009 4:30 PM In reply to

    Re: Xbox FileStream.BeginWrite NotSupported?

    dadoo Games:
    It is not supported on the compact framework, which is what the Xbox uses. The documentation at the bottom of the MSDN page for FileStream.BeginWrite lists the frameworks that support the method, and the compact framework is (correctly) not listed.


    http://msdn.microsoft.com/en-us/library/t7e3td2c(VS.71).aspx

    It lists the compact framework on that page? It lists CF 1.0 and 2.0 in my local MSDN as well (only 2005 so dunno about .NET 3.0+)
    PebbleDash - Released
    Abstacked - Released
  • 5/19/2009 4:39 PM In reply to

    Re: Xbox FileStream.BeginWrite NotSupported?

    I only checked the MSDN for the current version http://msdn.microsoft.com/en-us/library/t7e3td2c.aspx which seems to do a better job listing specific platforms on a per-member basis than the older versions.
  • 5/19/2009 5:17 PM In reply to

    Re: Xbox FileStream.BeginWrite NotSupported?

    lutas:
    dadoo Games:
    It is not supported on the compact framework, which is what the Xbox uses. The documentation at the bottom of the MSDN page for FileStream.BeginWrite lists the frameworks that support the method, and the compact framework is (correctly) not listed.


    http://msdn.microsoft.com/en-us/library/t7e3td2c(VS.71).aspx

    It lists the compact framework on that page? It lists CF 1.0 and 2.0 in my local MSDN as well (only 2005 so dunno about .NET 3.0+)
    As confusing as it is, having it list CF is not what you need. If it is supported on the Xbox 360 there will be a listing for supporting the XNA Framework in addition to .NET or .NET CF. Take a look at the listing for something like the List<T> class to see what that looks like. I wish it were less confusing (as I'm not sure why something would support .NET CF but not XNA Framework on the Xbox 360), but that's how it is.
  • 5/20/2009 7:29 PM In reply to

    Re: Xbox FileStream.BeginWrite NotSupported?

    Thanks for all the replies, I am usually pretty good at spotting these things but for once it evaded me and I wanted to confirm this really was unsupported which you guys did so thanks.

    In the meantime I rolled my own async write/load routines to replace this and it works perfectly on both pc and xbox :)

    Thanks again, René

  • 11/14/2009 7:16 PM In reply to

    Re: Xbox FileStream.BeginWrite NotSupported?

    How else can you open up an XML file then? I am using a map editor called GLEED2D and it saves everything in an XML file. It came with its own object to load in maps but it uses FileStream and doesn't work on the Xbox. How else can I do this?

    This is where the error occurs and shows a little on how it reads the XML File:

           public static Level FromFile(string filename, ContentManager cm)
            {
                FileStream stream = File.Open(filename, FileMode.Open);     //exception occurs here!
                XmlSerializer serializer = new XmlSerializer(typeof(Level));
                Level level = (Level)serializer.Deserialize(stream);
                stream.Close();

                foreach (Layer layer in level.Layers)
                {
                    foreach (Item item in layer.Items)
                    {
                        item.CustomProperties.RestoreItemAssociations(level);
                        item.load(cm);
                    }
                }

                return level;
            }

    The actual exception says "System.UnauthorizedAccessException".


    UPDATE!! 
    All I had to do was change "FileStream stream = File.Open(filename, FileMode.Open);" to "Stream stream = File.OpenRead(filename);".
    Works fine now :)
Page 1 of 1 (8 items) Previous Next