本文整理汇总了C#中FileStream.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# FileStream.ToString方法的具体用法?C# FileStream.ToString怎么用?C# FileStream.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStream
的用法示例。
在下文中一共展示了FileStream.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecryptFile
public static string DecryptFile(string filePath)
{
Debug.Log("Decrypting");
var output = String.Empty;
try
{
using (RijndaelManaged aes = new RijndaelManaged())
{
byte[] key = ASCIIEncoding.UTF8.GetBytes(skey);
byte[] IV = ASCIIEncoding.UTF8.GetBytes(vkey);
using (FileStream fsCrypt = new FileStream(filePath + "eSave.dat", FileMode.Open))
{
using (FileStream fsOut = new FileStream(filePath + "uSave.dat", FileMode.Create))
{
using (ICryptoTransform decryptor = aes.CreateDecryptor(key, IV))
{
using (CryptoStream cs = new CryptoStream(fsCrypt, decryptor, CryptoStreamMode.Read))
{
int data;
while ((data = cs.ReadByte()) != -1)
{
fsOut.WriteByte((byte)data);
}
output = fsOut.ToString();
}
}
}
}
}
//File.Delete(filePath + "uSave.dat");
}
catch{} // failed to decrypt file
return output;
}
示例2: SaveLead
private string SaveLead()
{
string date = DateTime.Now.ToString("yyyyMMdd");
string filename = sftpfolder + "\\" + date + "_ioc_cardlite" + ".txt";
if (Request.Form["form_id"] == "frmrejsuviocrlp")
{
filename = sftpfolder + "\\" + date + "_ioc_cardlite_reject" + ".txt";
}
else if ((Request.Form["form_id"] == "frmsho2suviocrlp") || (Request.Form["form_id"] == "frmshosuviocrlp") || (Request.Form["form_id"] =="frmsuviocrlpshortlead"))
{
filename = sftpfolder + "\\" + date + "_ioc_cardlite_shortlead" + ".txt";
}
FileStream fileStream;
int id = 1;
DateTime currentDatetime = DateTime.Now;
string orderIdDate = currentDatetime.ToString("ddMMyyyy_HHmmss");
StringBuilder sb = new StringBuilder();
if (!System.IO.File.Exists(filename))
{
fileStream = new FileStream(filename, FileMode.Create);
fileStream.Flush();
fileStream.Dispose();
fileStream.Close();
}
else
{
if (System.IO.File.Exists(filename))
{
fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
string strFileText = fileStream.ToString();
if (fileStream.Length > 0)
{
StreamReader sr = new StreamReader(filename);
string strLine;
string lastSap = string.Empty;
strLine = sr.ReadLine();
while (strLine != null)
{
//Read the next line
strLine = sr.ReadLine();
if (strLine != null)
{
if (strLine.Contains("SAP"))
{
lastSap = strLine.Substring(strLine.IndexOf("SAP"));
int lenght = (strLine.IndexOf("|")) - (strLine.IndexOf("SAP")) - 3;
id = Convert.ToInt16(lastSap.Substring(3, lenght)) + 1;
}
}
}
sr.Dispose();
sr.Close();
}
fileStream.Flush();
fileStream.Dispose();
fileStream.Close();
}
}
string orderId = orderIdDate + "_" + "SAP" + id;
sb.Append(orderId + "||TrandDt||" + date);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Channel||MEDIA");
sb.Append(Environment.NewLine);
sb.Append(orderId + "||externalOfferCode||" + Request.Form["externalOfferCode"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Reference from short leads||" + Request.Form["orderID"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Title||" + Request.Form["Title"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||FirstName||" + Request.Form["FirstName"] );
sb.Append(Environment.NewLine);
sb.Append(orderId + "||MiddleName||" + Request.Form["MiddleName"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||LastName||" + Request.Form["LastName"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||DOB||" + Request.Form["dob_dd"] + "-" + Request.Form["dob_mm"] + "-" + Request.Form["dob_yy"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Pan Card Number||" + Request.Form["Pan Card Number"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Residential_Address||" + Request.Form["Residence Door"] + ", " + Request.Form["Residence Street Name"] + ", " + Request.Form["Residence Area"] + ", " + Request.Form["Residence Landmark"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Residence City||" + Request.Form["Residence City"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Residence Pincode||" + Request.Form["Residence Pincode"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||resi_std_no||" + Request.Form["resi_std_no"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Residence Phone Number||" + Request.Form["Residence Phone Number"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Mobile||" + Request.Form["Mobile"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Email_Id||" + Request.Form["Email_Id"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||OFF_NAME||" + Request.Form["OFF_NAME"]);
sb.Append(Environment.NewLine);
sb.Append(orderId + "||Office STD Code||" + Request.Form["Office STD Code"]);
//.........这里部分代码省略.........