 |
|
อ่านไฟล์ txt ทีละบรรทัด และไฟล์จากโฟลเดอร์ และ สุ่มบรรทัดจากไฟล์ แต่มันได้ค่าเดิม เป็นเพราะอะไรครับ
คือ จะสุ่มไฟล์ template ที่เป็น .html มาจากโฟลเดอร์หนึ่ง มาและ สุ่มบรรทัดจากไฟล์มาแต่มันได้ค่าเดิมอะครับ พอเขียน messagebox.show มันไม่ได้ค่าเดิม แต่พอไม่ได้มันได้ค่าเดิมอะครับ
Code (C#)
if (comboBox1.SelectedItem.ToString() == "Amazon")
{
affpathname = affcase1;
}
else if (comboBox1.SelectedItem.ToString() == "Clickbank")
{
affpathname = affcase2;
}
int postpermm = Convert.ToInt32(postperm.Text);
this.timer1.Start();
string pfile = textBox1.Text;
DateTime startdatef = dateTimePicker1.Value;
string startdateshorta = string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"), "{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now);
FileStream FileOut = new FileStream(Application.StartupPath + @"\" + "wordpress" + @"\" + startdateshorta + ".xml", FileMode.Create);
StreamWriter sw = new StreamWriter(FileOut);
StreamReader a = new StreamReader(pfile);
string dd = null;
while ((dd = a.ReadLine()) != null)
{
{
var rand = new Random();
IEnumerable<string> lines = File.ReadLines(@Application.StartupPath + @"\config\" + affpathname + @"\title_template.txt");
var lineToRead = rand.Next(1, lines.Count());
var line = lines.Skip(lineToRead - 1).First();
sw.Write(line);
sw.Write("\r\n");
}
{
var rr = new Random();
var files = Directory.GetFiles(@Application.StartupPath + @"\config\" + affpathname + @"\layout\", "*.*").Where(s => Regex.Match(s, @"\.(html|htm)$").Success);
string randFile = files.ToList()[rr.Next(0, files.Count())];
sw.Write(randFile);
sw.Write("\r\n");
sw.Write("\r\n");
}
if (comboBox1.SelectedItem.ToString() == "Amazon")
{
affpathname = affcase1;
}
else if (comboBox1.SelectedItem.ToString() == "Other Aff")
{
affpathname = affcase9;
}
string startdatelong = string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"), "{0:ddd, dd MMM yyyy HH:mm:ss}", startdatef);
string todaydatelong = string.Format(System.Globalization.CultureInfo.CreateSpecificCulture("en-US"), "{0:ddd, dd MMM yyyy HH:mm:ss}", DateTime.Now);
string[] arr1 = dd.Split('@');
{
string productname = arr1[0];
string productimg = arr1[1];
string productlink = null;
if (mutiaff.Checked)
{
productlink = arr1[2];
}
else
{
productlink = singleafflink.Text;
}
}
}
sw.Write("</channel>\r\n");
sw.Write("</rss>\r\n");
sw.Close();
FileOut.Close();
}
Tag : .NET, VS 2012 (.NET 4.x)
|
|
 |
 |
 |
 |
Date :
2013-09-15 20:08:16 |
By :
nui |
View :
998 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |