public FileReverseReader(string path) { disposed = false; file = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); encoding = FindEncoding(file); SetupCharacterStartDetector(); }
/// <summary> /// Запись в ЛОГ-файл /// </summary> /// <param name="str"></param> public void WriteToLog(string str, bool doWrite = true) { if (doWrite) { StreamWriter sw = null; FileStream fs = null; try { string curDir = AppDomain.CurrentDomain.BaseDirectory; fs = new FileStream(curDir + "teplouchetlog.pi", FileMode.Append, FileAccess.Write, FileShare.ReadWrite); sw = new StreamWriter(fs, Encoding.Default); if (m_vport == null) sw.WriteLine(DateTime.Now.ToString() + ": Unknown port: adress: " + m_address + ": " + str); else sw.WriteLine(DateTime.Now.ToString() + ": " + m_vport.GetName() + ": adress: " + m_address + ": " + str); sw.Close(); fs.Close(); } catch { } finally { if (sw != null) { sw.Close(); sw = null; } if (fs != null) { fs.Close(); fs = null; } } } }
public Tkhd(FileStream fs) { Buffer = new byte[84]; int bytesRead = fs.Read(Buffer, 0, Buffer.Length); if (bytesRead < Buffer.Length) return; int version = Buffer[0]; int addToIndex64Bit = 0; if (version == 1) addToIndex64Bit = 8; TrackId = GetUInt(12 + addToIndex64Bit); if (version == 1) { Duration = GetUInt64(20 + addToIndex64Bit); addToIndex64Bit += 4; } else { Duration = GetUInt(20 + addToIndex64Bit); } Width = (uint)GetWord(76 + addToIndex64Bit); // skip decimals Height = (uint)GetWord(80 + addToIndex64Bit); // skip decimals //System.Windows.Forms.MessageBox.Show("Width: " + GetWord(76 + addToIndex64Bit).ToString() + "." + GetWord(78 + addToIndex64Bit).ToString()); //System.Windows.Forms.MessageBox.Show("Height: " + GetWord(80 + addToIndex64Bit).ToString() + "." + GetWord(82 + addToIndex64Bit).ToString()); }
/// <summary> /// Determines whether the file specified by its path is a PDF file by inspecting the first eight /// bytes of the data. If the file header has the form «%PDF-x.y» the function returns the version /// number as integer (e.g. 14 for PDF 1.4). If the file header is invalid or inaccessible /// for any reason, 0 is returned. The function never throws an exception. /// </summary> public static int TestPdfFile(string path) { FileStream stream = null; try { int pageNumber; string realPath = PdfSharp.Drawing.XPdfForm.ExtractPageNumber(path, out pageNumber); if (File.Exists(realPath)) // prevent unwanted exceptions during debugging { stream = new FileStream(realPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); byte[] bytes = new byte[1024]; stream.Read(bytes, 0, 1024); return GetPdfFileVersion(bytes); } } catch { } finally { try { if (stream != null) stream.Close(); } catch { } } return 0; }
static RadarColorData() { using (FileStream index = new FileStream(FileManager.GetFilePath("Radarcol.mul"), FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryReader bin = new BinaryReader(index); // Prior to 7.0.7.1, all clients have 0x10000 colors. Newer clients have fewer colors. int colorCount = (int)index.Length / 2; for (int i = 0; i < colorCount; i++) { uint c = bin.ReadUInt16(); Colors[i] = 0xFF000000 | ( ((((c >> 10) & 0x1F) * multiplier)) | ((((c >> 5) & 0x1F) * multiplier) << 8) | (((c & 0x1F) * multiplier) << 16) ); } // fill the remainder of the color table with non-transparent magenta. for (int i = colorCount; i < Colors.Length; i++) { Colors[i] = 0xFFFF00FF; } Metrics.ReportDataRead((int)bin.BaseStream.Position); } }
public void AppendTest() { /* * TODO : Add proper values for * infile : signed file without payload * outFile : file to be written * outFile : reference file. A working file wher payload already appended */ var inFile = ""; var outFile = ""; var reference = ""; var payload = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?></xml>"; if (File.Exists(inFile)) { using (var inputFile = File.OpenRead(inFile)) { using (var outputFile = new FileStream(outFile, FileMode.OpenOrCreate)) { Payload.Append(inputFile, outputFile, payload); } } var actual = File.ReadAllBytes(outFile); var expected = File.ReadAllBytes(reference); Assert.AreEqual(expected, actual); } }
/// 获取token,如果存在且没过期,则直接取token /// <summary> /// 获取token,如果存在且没过期,则直接取token /// </summary> /// <returns></returns> public static string GetExistAccessToken() { // 读取XML文件中的数据 string filepath = System.Web.HttpContext.Current.Server.MapPath("/XMLToken.xml"); FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); StreamReader str = new StreamReader(fs, System.Text.Encoding.UTF8); XmlDocument xml = new XmlDocument(); xml.Load(str); str.Close(); str.Dispose(); fs.Close(); fs.Dispose(); string Token = xml.SelectSingleNode("xml").SelectSingleNode("AccessToken").InnerText; DateTime AccessTokenExpires = Convert.ToDateTime(xml.SelectSingleNode("xml").SelectSingleNode("AccessExpires").InnerText); //如果token过期,则重新获取token if (DateTime.Now >= AccessTokenExpires) { AccessToken mode = Getaccess(); //将token存到xml文件中,全局缓存 xml.SelectSingleNode("xml").SelectSingleNode("AccessToken").InnerText = mode.access_token; DateTime _AccessTokenExpires = DateTime.Now.AddSeconds(mode.expires_in); xml.SelectSingleNode("xml").SelectSingleNode("AccessExpires").InnerText = _AccessTokenExpires.ToString(); xml.Save(filepath); Token = mode.access_token; } return Token; }
// use static factory methods! private GnuPlot(Table table) { try { // TODO avoid necessary write access in app directory using (FileStream fs = new FileStream (BinaryFile, FileMode.Create, FileAccess.Write)) using (BinaryWriter bw = new BinaryWriter (fs)) { Table3D t3D = table as Table3D; if (t3D != null) WriteGnuPlotBinary (bw, t3D); else WriteGnuPlotBinary (bw, (Table2D)table); } } catch (Exception ex) { throw new GnuPlotException ("Could not write binary data file.\n" + ex.Message); } try { StartProcess (table); } catch (System.ComponentModel.Win32Exception ex) { // from MSDN // These are the Win32 error code for file not found or access denied. const int ERROR_FILE_NOT_FOUND = 2; const int ERROR_ACCESS_DENIED = 5; switch (ex.NativeErrorCode) { case ERROR_FILE_NOT_FOUND: throw new GnuPlotProcessException ("Could not find gnuplot executable path:\n" + exePath + "\n\n" + ex.Message); case ERROR_ACCESS_DENIED: throw new GnuPlotProcessException ("Access denied, no permission to start gnuplot process!\n" + ex.Message); default: throw new GnuPlotProcessException ("Unknown error. Could not start gnuplot process.\n" + ex.Message); } } }
static void Main(string[] args) { VTDGen vg = new VTDGen(); AutoPilot ap = new AutoPilot(); Encoding eg = System.Text.Encoding.GetEncoding("utf-8"); //ap.selectXPath("/*/*/*"); AutoPilot ap2 = new AutoPilot(); ap2.selectXPath("//@*"); if (vg.parseFile("soap2.xml", true)) { FileStream fs = new FileStream("output.xml", System.IO.FileMode.OpenOrCreate); VTDNav vn = vg.getNav(); ap.bind(vn); ap2.bind(vn); //ap.evalXPath(); int i; while ((i = ap2.evalXPath()) != -1) { //System.out.println("attr name ---> "+ i+ " "+vn.toString(i)+" value ---> "+vn.toString(i+1)); vn.overWrite(i + 1, eg.GetBytes("")); } byte[] ba = vn.getXML().getBytes(); fs.Write(ba,0,ba.Length); fs.Close(); } }
/* * Append active keymaps to a given file. */ public static void dump(FileStream fff) { throw new NotImplementedException(); //int mode; //Keymap k; //if (OPT(rogue_like_commands)) // mode = KEYMAP_MODE_ROGUE; //else // mode = KEYMAP_MODE_ORIG; //for (k = keymaps[mode]; k; k = k.next) { // char buf[1024]; // keypress key[2] = { { 0 }, { 0 } }; // if (!k.user) continue; // /* Encode the action */ // keypress_to_text(buf, sizeof(buf), k.actions, false); // file_putf(fff, "A:%s\n", buf); // /* Convert the key into a string */ // key[0] = k.key; // keypress_to_text(buf, sizeof(buf), key, true); // file_putf(fff, "C:%d:%s\n", mode, buf); // file_putf(fff, "\n"); //} }
//Base method - most simple implementation static void filestream(string filePath, Action<string> callback) { byte[] buffer = new byte[BUFFER_SIZE]; byte[] charBuffer = new byte[MAX_TOKEN_SIZE]; int charIndex = 0; int bufferSize; using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { do { bufferSize = stream.Read(buffer, 0, BUFFER_SIZE); for (int i = 0; i < bufferSize; i++) { if (scannerNoMatch(buffer[i])) { charBuffer[charIndex++] = buffer[i]; } else { callback(ENCODING.GetString(charBuffer, 0, charIndex)); charIndex = 0; } } } while (bufferSize != 0); } }
public void run(string text) { iSpeechSynthesis iSpeech= new iSpeechSynthesis(_api, _production); iSpeech.setVoice("usenglishfemale"); iSpeech.setOptionalCommands("format", "mp3"); TTSResult result = iSpeech.speak(text); byte [] audioData = new byte[result.getAudioFileLength()]; int read = 0; int totalRead = 0; while (totalRead < audioData.Length) { read = result.getStream().Read(audioData, totalRead, audioData.Length - totalRead); totalRead += read; } FileStream fs = new FileStream("audio.mp3", FileMode.Create); BinaryWriter bw = new BinaryWriter(fs); bw.Write(audioData, 0, audioData.Length); }
public void Load(BinaryReader br, FileStream fs) { Offset = br.ReadInt32(); Offset += 16; FrameCount = br.ReadInt32(); MipWidth = br.ReadInt32(); MipHeight = br.ReadInt32(); StartX = br.ReadInt32(); StartY = br.ReadInt32(); TileCount = br.ReadUInt16(); TotalCount = br.ReadUInt16(); CellWidth = br.ReadUInt16(); CellHeight = br.ReadUInt16(); Frames = new EanFrame[TotalCount]; long curPos = fs.Position; fs.Seek((long)Offset, SeekOrigin.Begin); for (int i = 0; i < TotalCount; i++) { Frames[i].X = br.ReadUInt16(); Frames[i].Y = br.ReadUInt16(); Frames[i].Width = br.ReadUInt16(); Frames[i].Height = br.ReadUInt16(); } fs.Seek((long)curPos, SeekOrigin.Begin); }
private static string DeCrypting() { var res = string.Empty; var file = new FileStream(Controller.GetPath(), FileMode.Open, FileAccess.Read, FileShare.None, 32, FileOptions.SequentialScan); var reader = new BinaryReader(file); var writer = new BinaryWriter(new FileStream(Processor.GetNewName(Controller.GetPath()), FileMode.Create, FileAccess.Write, FileShare.None, 32, FileOptions.WriteThrough)); try { var pos = 0; while (pos < file.Length) { var c = reader.ReadUInt16(); //var pow = Processor.fast_exp(c, Controller.GetKc(), Controller.GetR()); var pow = Processor.Pows(c, Controller.GetKc(), Controller.GetR()); if (pos < 256) res += pow + " "; writer.Write((byte)(pow)); pos += 2; } } finally { writer.Close(); reader.Close(); } return "Decoding Complete!\n" + res; }
void addConfigFile(string configFilename) { var dirName = Utils.getDirName(Utils.getFullPath(configFilename)); addAssemblySearchPath(dirName); try { using (var xmlStream = new FileStream(configFilename, FileMode.Open, FileAccess.Read, FileShare.Read)) { var doc = new XmlDocument(); doc.Load(XmlReader.Create(xmlStream)); foreach (var tmp in doc.GetElementsByTagName("probing")) { var probingElem = tmp as XmlElement; if (probingElem == null) continue; var privatePath = probingElem.GetAttribute("privatePath"); if (string.IsNullOrEmpty(privatePath)) continue; foreach (var path in privatePath.Split(';')) addAssemblySearchPath(Path.Combine(dirName, path)); } } } catch (IOException) { } catch (XmlException) { } }
public void ConnectExistingStream(string path, bool readOnly = true) { Stream.Dispose(); Stream = null; Debug.GC(true); Stream = new FileStream(path, FileMode.Open); IsReadOnly = readOnly; }
static void Main(string[] args) { //AsyncReadOneFile(); //AsyncReadMultiplyFiles(); FileStream fs = new FileStream(@"../../Program.cs", FileMode.Open, FileAccess.Read, FileShare.Read, 1024, FileOptions.Asynchronous); Byte[] data = new Byte[100]; IAsyncResult ar = fs.BeginRead(data, 0, data.Length, null, null); while (!ar.IsCompleted) { Console.WriteLine("Операция не завершена, ожидайте..."); Thread.Sleep(10); } Int32 bytesRead = fs.EndRead(ar); fs.Close(); Console.WriteLine("Количество считаных байт = {0}", bytesRead); Console.WriteLine(Encoding.UTF8.GetString(data).Remove(0, 1)); }
/// <summary> /// Loads materials from the specified stream. /// </summary> /// <param name="path">The path.</param> /// <param name="loadTextureImages">if set to <c>true</c> texture images /// will be loaded and set in the <see cref="TextureMap.Image"/> property.</param> /// <returns>The results of the file load.</returns> public static FileLoadResult<List<Material>> Load(string path, bool loadTextureImages) { // Create a streamreader and read the data. using(var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var streamReader = new StreamReader(stream)) return Read(streamReader, path, loadTextureImages); }
public static String Reader() { try { FileStream fs = new FileStream(getURL(), FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read); StreamReader r = new StreamReader(fs); hostsFile = r.ReadToEnd(); r.Close(); fs.Close(); return hostsFile; } catch (UnauthorizedAccessException) { return "Access denied"; } catch (IOException) { return "Host not found."; } catch (ArgumentException) { return "Please, enter IP Address or Host name."; } catch (Exception) { return null; } }
public static void Main() { #if NETDUINO_MINI StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_13); #else StorageDevice.MountSD("SD", SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10); #endif using (var filestream = new FileStream(@"SD\resources.txt", FileMode.Open)) { StreamReader reader = new StreamReader(filestream); Debug.Print(reader.ReadToEnd()); reader.Close(); } using (var filestream = new FileStream(@"SD\dontpanic.txt", FileMode.Create)) { StreamWriter streamWriter = new StreamWriter(filestream); streamWriter.WriteLine("This is a test of the SD card support on the netduino...This is only a test..."); streamWriter.Close(); } StorageDevice.Unmount("SD"); }
/// <summary> /// Write the data of each frame in the file. /// </summary> /// <param name="controller">Controller that represent the device.</param> /// <param name="path">Path of the file where the data will be write.<br/> /// If one already exist it will be deleted and a new empty on is created.</param> public void RecordData(Controller controller, String path) { if (Directory.Exists(path) == true) { String destination = path + "leapMotion.data"; try { if (File.Exists(destination) == true) File.Delete(destination); file = File.Create(destination); } catch (ArgumentException e) { throw e; } } else throw new System.ArgumentException("Destination path doesn't exist", "path"); BinaryWriter writer = new BinaryWriter(file); for (int f = 9; f >= 0; f--) { Frame frameToSerialize = controller.Frame(f); byte[] serialized = frameToSerialize.Serialize; Int32 length = serialized.Length; writer.Write(length); writer.Write(serialized); } }
static void Main(string[] args) { FileStream filStream; BinaryWriter binWriter; Console.Write("Enter name of the file: "); string fileName = Console.ReadLine(); if (File.Exists(fileName)) { Console.WriteLine("File - {0} already exists!", fileName); } else { filStream = new FileStream(fileName, FileMode.CreateNew); binWriter = new BinaryWriter(filStream); decimal aValue = 2.16M; binWriter.Write("Sample Run"); for (int i = 0; i < 11; i++) { binWriter.Write(i); } binWriter.Write(aValue); binWriter.Close(); filStream.Close(); Console.WriteLine("File Created successfully"); } Console.ReadKey(); }
public static void SaveFolderFile(IList<PathItem> folders, string path) { FileStream fileStream = null; StreamWriter streamWriter = null; try { if (folders != null) { fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); streamWriter = new StreamWriter(fileStream); foreach (PathItem item in folders) { string line = String.Format("<folder name=\"{0}\" path=\"{1}\" />", item.Name, item.Path); streamWriter.WriteLine(line); } streamWriter.Close(); streamWriter = null; fileStream.Close(); fileStream = null; } } catch (Exception ex) { System.Diagnostics.Trace.TraceError("Error saving Favorites list [{0}]:\r\n{1}\r\n{2}",path,ex.Message,ex.StackTrace); throw; } finally { if (streamWriter != null) streamWriter.Close(); if (fileStream != null) fileStream.Close(); } }
void FileClose() { fileStream.Flush(); fileStream.Close(); fileStream.Dispose(); fileStream = null; }
public void Write(string path) { using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write)) { Write(fs); } }
public byte[] FilenameToBytes(string filename) { byte[] data = null; // get the file information form the selected file FileInfo fInfo = new FileInfo(filename); // get the length of the file to see if it is possible // to upload it (with the standard 4 MB limit) long numBytes = fInfo.Length; double dLen = Convert.ToDouble(fInfo.Length / 1000000); // set up a file stream and binary reader for the // selected file FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fStream); // convert the file to a byte array data = br.ReadBytes((int)numBytes); br.Close(); fStream.Close(); fStream.Dispose(); return data; }
//This method improves upon the naive method (stringBuffer) as ENCODING.GetString //allocates a new character array with every invocation, and this method bypasses //this by reusing the same char array. Surprisingly in tests, this method held //no improvement. static void filestream2(string filePath, Action<string> callback) { byte[] buffer = new byte[BUFFER_SIZE]; byte[] charBuffer = new byte[MAX_TOKEN_SIZE]; char[] encoderBuffer = new char[ENCODING.GetMaxCharCount(MAX_TOKEN_SIZE)]; int charIndex = 0; int bufferSize, encodedChars; using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { do { bufferSize = stream.Read(buffer, 0, BUFFER_SIZE); for (int i = 0; i < bufferSize; i++) { if (scannerNoMatch(buffer[i])) { charBuffer[charIndex++] = buffer[i]; } else { encodedChars = ENCODING.GetChars(charBuffer, 0, charIndex, encoderBuffer, 0); callback(new string(encoderBuffer, 0, encodedChars)); charIndex = 0; } } } while (bufferSize != 0); } }
public void AddFontFile(string filename) { using(FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { io.InputStream stream = vmw.common.IOUtils.ToInputStream (fs); awt.Font font = awt.Font.createFont(awt.Font.TRUETYPE_FONT, stream); AddFont(font); } }
public Mdia(FileStream fs, ulong maximumLength) { Position = (ulong)fs.Position; while (fs.Position < (long)maximumLength) { if (!InitializeSizeAndName(fs)) return; if (Name == "minf" && IsTextSubtitle || IsVobSubSubtitle || IsClosedCaption || IsVideo) { UInt32 timeScale = 90000; if (Mdhd != null) timeScale = Mdhd.TimeScale; Minf = new Minf(fs, Position, timeScale, HandlerType, this); } else if (Name == "hdlr") { Buffer = new byte[Size - 4]; fs.Read(Buffer, 0, Buffer.Length); HandlerType = GetString(8, 4); if (Size > 25) HandlerName = GetString(24, Buffer.Length - (24 + 5)); // TODO: How to find this? } else if (Name == "mdhd") { Mdhd = new Mdhd(fs, Size); } fs.Seek((long)Position, SeekOrigin.Begin); } }
public static byte[] ReadBinaryFile(string FileName) { FileStream BinaryStream = new FileStream(FileName, FileMode.Open); byte[] retBytes = null; BinaryStream.Read(retBytes, 0, BinaryStream.Length); return retBytes; }
public static QUPC_MT160008UK05PSISDocMetaData LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static QUPA_MT000001UK01PersonadministrativeGenderCode LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
/* * 使用binary序列化1000个对象,Person.dat大小为:54.1 KB (55,445 字节) */ public static void TestMethod4() { var list = new List <Person>(); for (var i = 0; i < 1000; i++) { var person = new Person { Id = i, Name = "Name" + i, Address = new Address { Line1 = "Line1", Line2 = "Line2" } }; list.Add(person); } using (var file = new System.IO.FileStream("Person.dat", System.IO.FileMode.Create)) { var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); binaryFormatter.Serialize(file, list); } }
public static COCD_TP147366GB01PhysicalWellBeingRef LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static UKCT_MT170001UK01ProcedureCommentary LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static COCD_TP146031UK04LastMedicationAdministrationReviewCode LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static PRPA_MT020101UK01ConfirmedService LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static PORX_MT024001UK31RequestedManufacturedProduct LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static CVNPfITCodedOriginaltextrequired LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static PRPA_MT000211UK03SuspectedCongenitalAbnormality LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static UKCT_MT144054UK01PertinentInformationSeperatableInd LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static COCD_TP146061UK01Section3TemplateId LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static PORX_MT014001UK06SuppliedLineItemQuantity LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static COCD_TP146308GB01ProblemMemberAssertionStatusCode LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static QUPA_IN000007UK01MCCI_MT020101UK12MessageVersionCode LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static POII_MT000002UK01ReplacementOf3 LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static REPC_MT400101UK07PertinentInformation14TemplateId LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static REPC_MT100101UK30CompleteLRList LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static POCD_MT170001UK06ClinicalDocumentEffectiveTime LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static allInfrastructureRoottypeId LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static PORX_IN050102UK32ControlActEvent LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static MCAI_MT040101UK03DetectedIssueEvent LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static UKCT_MT144035UK01ThirdPartyCorrespondence LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static UKCT_MT130801UK03PrimaryInformationRecipient LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static COCT_MT000200UK02InitialNHAISRegistrationEventEffectiveTime LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static PORX_MT142004UK31PrescriptionStatus LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static PORX_MT024003UK06CareRecordElementCategory LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
public static RCMR_MT030101UK04ResponsibleParty3 LoadFromFile(string fileName) { System.IO.FileStream file = null; System.IO.StreamReader sr = null; try { file = new System.IO.FileStream(fileName, FileMode.Open, FileAccess.Read); sr = new System.IO.StreamReader(file); string xmlString = sr.ReadToEnd(); sr.Close(); file.Close(); return(Deserialize(xmlString)); } finally { if ((file != null)) { file.Dispose(); } if ((sr != null)) { sr.Dispose(); } } }
private void btnTestWaveStream_Click(object sender, System.EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Open Wave Audio..."; ofd.Filter = "Wave Files (*.wav)|*.wav"; ofd.FilterIndex = 1; if (ofd.ShowDialog() == DialogResult.OK) { var stream = new System.IO.FileStream(ofd.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read, 16 * 1024); #if ERNST_DX_AUDIO _Player = new WavePlayer(); _Player = new WavePlayer( this, stream ); _Player.BufferLength = 1000; #else _Player.Stream = stream; _Player.Play(); #endif } }
public void DownloadFile(string URL, string filename, System.Windows.Forms.ProgressBar prog) { float percent = 0; try { System.Net.HttpWebRequest Myrq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(URL); System.Net.HttpWebResponse myrp = (System.Net.HttpWebResponse)Myrq.GetResponse(); long totalBytes = myrp.ContentLength; if (prog != null) { prog.Maximum = (int)totalBytes; } System.IO.Stream st = myrp.GetResponseStream(); System.IO.Stream so = new System.IO.FileStream(filename, System.IO.FileMode.Create); long totalDownloadedByte = 0; byte[] by = new byte[1024]; int osize = st.Read(by, 0, (int)by.Length); while (osize > 0) { totalDownloadedByte = osize + totalDownloadedByte; so.Write(by, 0, osize); if (prog != null) { prog.Value = (int)totalDownloadedByte; } osize = st.Read(by, 0, (int)by.Length); percent = (float)totalDownloadedByte / (float)totalBytes * 100; } so.Close(); st.Close(); } catch (System.Exception e) { MessageBox.Show(e.Message); } }