把总配置文件得到目录 ,然后放到ArrayList里面,然后再读出来, public static void Run(ArrayList ss)
{
foreach (string s in ss)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = s;//@"d:\DownLoads";//args[1];
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
//watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
// | NotifyFilters.FileName | NotifyFilters.DirectoryName;
//// Only watch text files.
watcher.Filter = "*.flv"; // Add event handlers.
//watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnCreated);
//watcher.Deleted += new FileSystemEventHandler(OnChanged);
//watcher.Renamed += new RenamedEventHandler(OnChanged); // Begin watching.
watcher.EnableRaisingEvents = true;
}
}
Code2
string fn = myQ.Dequeue();
string temp = new FileInfo(fn).FullName;
Process P = Process.Start("flvmdi.exe," + temp);
WriteLog(fn, name);c:\\Downloads\\出现两个斜杠,应该怎么办
{
foreach (string s in ss)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = s;//@"d:\DownLoads";//args[1];
/* Watch for changes in LastAccess and LastWrite times, and
the renaming of files or directories. */
//watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
// | NotifyFilters.FileName | NotifyFilters.DirectoryName;
//// Only watch text files.
watcher.Filter = "*.flv"; // Add event handlers.
//watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnCreated);
//watcher.Deleted += new FileSystemEventHandler(OnChanged);
//watcher.Renamed += new RenamedEventHandler(OnChanged); // Begin watching.
watcher.EnableRaisingEvents = true;
}
}
Code2
string fn = myQ.Dequeue();
string temp = new FileInfo(fn).FullName;
Process P = Process.Start("flvmdi.exe," + temp);
WriteLog(fn, name);c:\\Downloads\\出现两个斜杠,应该怎么办
解决方案 »
- Dictionary 没有先后顺序.?
- 广州朋友来说说请人做这种类似网站,要花多少钱?
- 一个字符串,如何让与它同名的函数执行?在线等
- 求救!为什么会出现未处理的“System.InvalidOperationException”类型的异常出现在 system.data.dll 中。
- 请教高手一个问题,急,谢谢!!System.Data.SqlClient.SqlException信息
- 如何使用panel进行分组控制的阿?
- 请各位帮帮忙,帮我看下,我这个代码问题出在哪里 关于SubmitChanges
- 问大神们一个高档上档次的问题?
- "高难度" 程序在运行时修改按钮、标签的文本
- 鼠标控制矩形旋转的方法
- 二进制文件,用文本打开,是乱码
- 怎么卸载.NetFrameWork1.1
/// Read Config File
/// </summary>
/// <returns></returns>
private static ArrayList readConfig()
{
string FilePath = Application.StartupPath + ConfigFile;
StreamReader sr = new StreamReader(FilePath, System.Text.Encoding.UTF8);
ArrayList list = new ArrayList(); try
{
while (sr.Peek() != -1)
{
string tmp = sr.ReadLine();
if (tmp != string.Empty || tmp != null)
{
list.Add(tmp);
}
}
}
catch (Exception fileex)
{
MessageBox.Show("File Exception:" + fileex.ToString());
}
return list;
}
private void btnStartWatching_Click(object sender, EventArgs e)
{
this.Text = "Watching ... ...";
ArrayList list = readConfig(); for (int i = 0; i < list.Count ; i++)
{
lbxFolderList.Items.Add(list[i]);
}
Run(list);
} public static void Run(ArrayList ss)
{
try
{
foreach (string s in ss)
{
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = s; watcher.Filter = "*.flv"; // Add event handlers.
//watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnCreated);
//watcher.Deleted += new FileSystemEventHandler(OnChanged);
//watcher.Renamed += new RenamedEventHandler(OnChanged); // Begin watching.
watcher.EnableRaisingEvents = true; }
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private static void OnCreated(object sender, FileSystemEventArgs e)
{
string name = e.Name;
string path = e.FullPath; try
{
//if file extension is flv
if (new FileInfo(path).Extension == ".flv")
{
myQ.Enqueue(path);
while (myQ.Count != 0)
{
string fn = myQ.Dequeue();
Process P = Process.Start("flvmdi.exe," +fn);
WriteLog(fn, name);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Exception Message:" + ex.ToString());
}
}