c# - xml file to mysql database -


i converting 3d objects 1 xml file, write hard drive, read hard drive , upload mysql database blob. delete created xml.file hard drive. somehow possible (create xml file/upload database) don't have write drive @ first, read it, delete it? if somehow create xml file , pass directly without need save on drive. ideas?

here write xml file drive (edited):

 public stream writexml(list<object> gridentities, string filename)         {             xdocument doc = new xdocument();             xelement root = new xelement("viewportlayout");             xelement xentities = new xelement("entities");              xentities.add(...);             root.add(xentities);             doc.add(root);             //var path = string.format("c:\\users\\np\\desktop\\saves\\{0}", filename);             //doc.save(path);              stream stream = new memorystream();  // create stream             doc.save(stream);      // save xdocument stream             stream.position = 0;   // rewind stream ready read elsewhere             return stream;         } 

here upload data base:

  public static void savegridxmlfiletodatabase(stream stream, string projectname, string filepath, string gridname, string gridguid)     {         if (openconnection() == true)         {             byte[] file;              using (stream)             {                 using (var reader = new binaryreader(stream))                 {                     file = reader.readbytes((int)stream.length);                 }             }             string project = string.concat(projectname, "_grids");              string query = string.format("insert {0} set name=@name, guid=@guid, xml=@file;", project);             using (var sqlwrite = new mysqlcommand(query, connection))             {                 sqlwrite.parameters.add("@name", mysqldbtype.varchar).value = gridname;                 sqlwrite.parameters.add("@guid", mysqldbtype.varchar).value = gridguid;                 sqlwrite.parameters.add("@file", mysqldbtype.longblob).value = file;                 sqlwrite.executenonquery();             }              closeconnection();         }     } 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -