本文整理汇总了C#中System.IO.StreamReader.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.ToString方法的具体用法?C# StreamReader.ToString怎么用?C# StreamReader.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了StreamReader.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: validateXMLSchema
/**
* Validate XML matches XSD. Stream-based method.
*
* @param xsdStream resource based path to XSD file
* @param xmlStream resource based path to XML file
* @throws IOException io exception for loading files
* @throws SAXException sax exception for parsing files
*/
/// <exception cref="IOException"></exception>
/// <exception cref="SAXException"></exception>
public static void validateXMLSchema(StreamReader xsdStream, StreamReader xmlStream) {
//SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
//Schema schema = factory.newSchema(new StreamSource(xsdStream));
//Validator validator = schema.newValidator();
//validator.validate(new StreamSource(xmlStream));
//XmlReaderSettings booksSettings = new XmlReaderSettings();
//booksSettings.Schemas.Add("http://www.contoso.com/books", "books.xsd");
//booksSettings.ValidationType = ValidationType.Schema;
//booksSettings.ValidationEventHandler += new ValidationEventHandler(booksSettingsValidationEventHandler);
//XmlReader books = XmlReader.Create("books.xml", booksSettings);
//while(books.Read()) {
//}
//XmlReader books = XmlReader.Create("books.xml", booksSettings);
//while(books.Read()) {
//}
XmlReaderSettings schema = new XmlReaderSettings();
schema.Schemas.Add("http://www.w3.org/2001/XMLSchema", xsdStream.ToString());
schema.ValidationType = ValidationType.Schema;
schema.ValidationEventHandler += new ValidationEventHandler(schemaValidationEventHandler);
}
示例2: Load
public static void Load(string filePath = "")
{
filePath = string.IsNullOrEmpty(filePath) ? ConfigFileName : filePath;
if (!File.Exists(filePath)) {
//TODO Create default config file.
Logger.Error("Config file not found");
return;
}
if (Properties == null) {
Properties = new Dictionary<string, string>();
}
using (StreamReader sr = new StreamReader(filePath)) {
string str;
if (sr.ToString().Length == 0) {
Logger.Error("Empty config file");
}
while ((str = sr.ReadLine()) != null) {
var key = str.Split('=')[0].Replace(" ", "");
var value = str.Split('=')[1].Replace(" ", "");
if (Properties.ContainsKey(key)) {
Properties[key] = value;
} else {
Properties.Add(key, value);
}
}
}
}
示例3: app_BeginRequest
void app_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.Clear();
// Check if ToWord exists in the query string parameters
if (HttpContext.Current.Request.QueryString["ToWord"] != null)
{
// Set the buffer to true
HttpContext.Current.Response.Buffer = true;
// Create a new HttpWebRequest to the same url
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(HttpContext.Current.Request.Url.ToString().Split('?')[0]);
// Set the credentials to default credentials: used if you are under proxy server
webRequest.Credentials = CredentialCache.DefaultCredentials;
// Get the response as stream
Stream stream = webRequest.GetResponse().GetResponseStream();
// Set the content type of the response on msword
HttpContext.Current.Response.ContentType = "application/msword";
// Read the response as string
string pageHTML = new StreamReader(stream).ReadToEnd();
// Write it to the response
HttpContext.Current.Response.Write(pageHTML.ToString());
// Complete the Request
((HttpApplication)sender).CompleteRequest();
// End the response.
HttpContext.Current.Response.End();
}
}
示例4: LoadFile
public void LoadFile(string path)
{
using (StreamReader reader = new StreamReader(path))
{
reader.ReadToEnd();
string fileContent = reader.ToString();
Parse(fileContent);
}
}
示例5: GET
public string GET(string method)
{
var request = (HttpWebRequest)WebRequest.Create(url+method);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
return responseString.ToString();
}
示例6: readFile
public String readFile(String fileName)
{
StreamReader objReader = new StreamReader(fileName, System.Text.Encoding.Default, true);
objReader.ToString();
String data = objReader.ReadToEnd();
String dataSend = setEncodeString(data);
// Console.WriteLine(dataSend);
return dataSend;
}
示例7: getTed
public String getTed(String fileName)
{
String ted = String.Empty;
String xml = String.Empty;
if (fileName != null)
{
StreamReader objReader = new StreamReader(fileName, System.Text.Encoding.Default, true);
objReader.ToString();
xml = objReader.ReadToEnd();
}
int start = xml.IndexOf("<TED");
int end = xml.IndexOf("</TED>");
int largo = (end+6) - start;
ted = xml.Substring(start, largo);
return ted;
}
示例8: lectura
public LibroCompra lectura()
{
LibroCompra lib = new LibroCompra();
fileAdmin file = new fileAdmin();
String fileName = file.nextFile(@"c:\IatFiles\file\", "*.json");
if (fileName != null)
{
//Paso la ruta del fichero al constructor
StreamReader objReader = new StreamReader(fileName, System.Text.Encoding.Default, true);
objReader.ToString();
String data = objReader.ReadToEnd();
DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(LibroCompra));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(data));
try
{
lib = (LibroCompra)js.ReadObject(ms);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
MessageBox.Show("Error de lectura JSON" + e.Message);
}
objReader.Close();
ms.Close();
file.mvFile(fileName, "C:/IatFiles/file/librocompra/", "C:/IatFiles/fileProcess/");
return lib;
}
else
{
return null;
}
}
示例9: POST
public string POST(string m_postData, string method)
{
var request = (HttpWebRequest)WebRequest.Create(url+method);
var postData = m_postData;
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
return responseString.ToString();
}
示例10: timerUserSync_Elapsed
void timerUserSync_Elapsed(object sender, ElapsedEventArgs e)
{
try
{
int.TryParse(ConfigurationManager.AppSettings["SyncUsersTime"], out timeUserSync);
timerUserSync.Interval = timeUserSync * 1000;
//Library.WriteErrorLog("Sync Users Logging Started ");
// call api and save the data from Json to SQL on web api
string con = ConfigurationManager.AppSettings["apiUrl"] + "JsonToSqlSync/1";
var request = (HttpWebRequest)WebRequest.Create(con);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
string s = responseString.ToString();
//Library.WriteDataLog(s);
//Library.WriteErrorLog("Sync Users Logged Successfully ");
}
catch (Exception ex)
{
Library.WriteErrorLog("timerUserSync_Elapsed: " + ex.ToString());
//Library.WriteDataLog(ex);
}
}
示例11: timerPingService_Elapsed
void timerPingService_Elapsed(object sender, ElapsedEventArgs e)
{
try
{
int.TryParse(ConfigurationManager.AppSettings["PingTime"], out timePing);
timerPingService.Interval = timePing * 1000;
string pingCheck = ConfigurationManager.AppSettings["startPingCheck"];
string s = string.Empty;
//Call Ping Status Check Controller
if (pingCheck.ToUpper() == "true".ToUpper() || pingCheck.ToUpper() == "t".ToUpper())
{
//Library.WriteErrorLog("Ping Data Logging Started " + timePing.ToString());
string conStatus = ConfigurationManager.AppSettings["apiUrl"] + "sitestatus";
HttpWebRequest requestStatus = (HttpWebRequest)WebRequest.Create(conStatus);
requestStatus.Timeout = 600 * 1000;
HttpWebResponse responseStatus = (HttpWebResponse)requestStatus.GetResponse();
var responseString = new StreamReader(responseStatus.GetResponseStream()).ReadToEnd();
s = responseString.ToString();
//Library.WriteDataLog(s);
//Library.WriteErrorLog("Ping Data Logged Successfully ");
}
}
catch (Exception ex)
{
Library.WriteErrorLog("timerPingService_Elapsed: " + ex.ToString());
//Library.WriteDataLog(ex);
}
}
示例12: timerMailQueueService_Elapsed
void timerMailQueueService_Elapsed(object sender, ElapsedEventArgs e)
{
try
{
int.TryParse(ConfigurationManager.AppSettings["MailQueueScheduleTime"], out timeMailQueue);
timerMailQueueService.Interval = timeMailQueue * 1000;
string MailQueueCheck = ConfigurationManager.AppSettings["MailQueueServiceEnabled"];
//Library.WriteErrorLog("Sync Daily Notifications Logging Started ");
if (MailQueueCheck.ToUpper() == "true".ToUpper() || MailQueueCheck.ToUpper() == "t".ToUpper())
{
// call api and save the data from Json to SQL on web api
string con = ConfigurationManager.AppSettings["apiUrl"] + "notifications/ExecuteMailQueue";
var request = (HttpWebRequest)WebRequest.Create(con);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
string s = responseString.ToString();
}
//Library.WriteDataLog(s);
//Library.WriteErrorLog("Sync Daily Notifications Logged Successfully ");
}
catch (Exception ex)
{
Library.WriteErrorLog("timerMailQueueService_Elapsed: " + ex.ToString());
}
}
示例13: lectura
public Documento lectura(String fileJson, bool moveFile, String dirOrigen)
{
Documento doc = new Documento();
fileAdmin file = new fileAdmin();
String fileName = String.Empty;
if (dirOrigen == "")
{
dirOrigen = @"C:\AdmToFebosFiles\files";
}
if (fileJson == "")
{
fileName = file.nextFile(dirOrigen, "*.json");
}
else
{
fileName = dirOrigen + fileJson;
}
if (fileName != null)
{
StreamReader objReader = new StreamReader(fileName,System.Text.Encoding.Default,true);
objReader.ToString();
String data = objReader.ReadToEnd();
DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(Documento));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(data));
try
{
doc = (Documento)js.ReadObject(ms);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
MessageBox.Show("Error de lectura JSON"+ e.Message);
}
// Datos del Emisor
// Cargo datos en laclase Documento desde sqlite
if (doc.RUTEmisor == null)
{
try
{
SQLiteConnection myConn = new SQLiteConnection(strConn);
myConn.Open();
string sql = "select * from empresa";
SQLiteCommand command = new SQLiteCommand(sql, myConn);
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
doc.RUTEmisor = reader["RutEmisor"].ToString();
doc.RznSoc = reader["RznSoc"].ToString();
doc.GiroEmis = reader["GiroEmis"].ToString();
doc.Telefono = reader["Telefono"].ToString();
doc.CorreoEmisor = reader["CorreoEmisor"].ToString();
doc.Acteco = Convert.ToInt32(reader["Acteco"]);
doc.CdgSIISucur = Convert.ToInt32(reader["CdgSIISucur"]);
doc.DirMatriz = reader["DirMatriz"].ToString();
doc.CmnaOrigen = reader["CmnaOrigen"].ToString();
doc.CiudadOrigen = reader["CiudadOrigen"].ToString();
doc.DirOrigen = reader["DirOrigen"].ToString();
doc.NombreCertificado = reader["NomCertificado"].ToString();
doc.SucurEmisor = reader["SucurEmisor"].ToString();
doc.FchResol = reader["FchResol"].ToString();
doc.RutEnvia = reader["RutCertificado"].ToString();
doc.NumResol = reader["NumResol"].ToString();
doc.CondEntrega = reader["CondEntrega"].ToString();
}
myConn.Close();
}
catch (Exception e)
{
Console.WriteLine("ERROR: {0}", e.ToString());
}
}
else
{
try
{
SQLiteConnection myConn = new SQLiteConnection(strConn);
myConn.Open();
string sql = "select * from empresa where empresa.RutEmisor = '"+ doc.RUTEmisor.ToString() +"'";
SQLiteCommand command = new SQLiteCommand(sql, myConn);
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
doc.Telefono = reader["Telefono"].ToString();
doc.CorreoEmisor = reader["CorreoEmisor"].ToString();
doc.Acteco = Convert.ToInt32(reader["Acteco"]);
//.........这里部分代码省略.........
示例14: AddNewClassNameToCompileSection
private static bool AddNewClassNameToCompileSection(StringBuilder sb, string line,
bool isAdded, StreamReader sr)
{
sb.AppendLine(line);
if (!line.Contains("<Compile Include=") || isAdded)
return isAdded;
if (sr.ToString().Contains("<Compile Include=" + '"' + sceneClassName + ".cs"))
return false;
sb.AppendLine("<Compile Include=" + '"' + sceneClassName + ".cs" + '"' + " />");
return true;
}
示例15: searchCustomer
public Customer searchCustomer(int customerID, string firstName, string lastName, string phoneNumber)
{
XmlDocument xml = new XmlDocument();
Customer customer = new Customer();
var request = (HttpWebRequest)WebRequest.Create(SERVICE_URL + "Customers/" + customerID);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
xml.LoadXml(responseString.ToString());
XmlNodeList nodes = xml.GetElementsByTagName("Customer");
foreach (XmlNode node in nodes)
{
XmlNodeList children = node.ChildNodes;
foreach (XmlNode child in children)
{
if (child.Name == "custID")
{
customer.customerID = Convert.ToInt32(child.InnerText);
}
else if (child.Name == "firstName")
{
customer.firstName = child.InnerText;
}
else if (child.Name == "lastName")
{
customer.lastName = child.InnerText;
}
else if (child.Name == "phoneNumber")
{
customer.phoneNumber = child.InnerText;
}
}
}
return customer;
}