用C#监视多个文件夹,然后调用flvmdi对这个flv文件进行信息注入.

10 篇文章 0 订阅

写一个应用程序,监视一个文件夹,如果文件里面有新的FLV文件,则调用flvmdi对这
个flv文件进行信息注入.

flvmdi文件我等会儿会放到你的共享文件里
关于flvmdi的用法可以查看:http://www.buraks.com/flvmdi/ 

 

 

private   const   string  FILE_PATH  =   @" C:Documents and SettingsAdministratorMy DocumentsVisual Studio 2005ProjectsWatchFolderWatchFolderinReleaseConfig.txt " ;

        
private   void  btnStartWatching_Click( object  sender, EventArgs e)
        
{
            
this.Text = "Watching ... ...";
            
string[] FileList = readFile();


            
this.FSWFileWatch.Path= FileList[1];
            
/*string[] cont = readFile();            

            for (int i = 1; i < cont.Length; i++)
            {
                if (cont.GetValue(i) != null)
                {
                    FileSystemWatcher FW = new FileSystemWatcher(cont.GetValue(i).ToString());
                    FW.Created += new FileSystemEventHandler(FSWFileWatch_Created);
                    FW.BeginInit();
                    FW.EnableRaisingEvents=true ;
                }
            } 
*/
                
        }
   

        
private   void  FSWFileWatch_Created( object  sender, System.IO.FileSystemEventArgs e)
        
{       
           
string name = e.Name;
           
string path = e.FullPath;
            
            
try
           
{

               
if (System.IO.Path.GetExtension(name) == ".flv")
               
{
                   Process P;
                   P 
= Process.Start("flvmdi.exe",path);

                   
if (P.HasExited)
                   

                        
//进程已经退出
                   }


                   
//MessageBox.Show("File " + name + "Created! Directory:" + path);
               }

           }

           
catch (Exception ex)
           
{
               MessageBox.Show(
"Exception Message:"+ex.ToString());
           }

            
        }


        
private   static   string [] readFile()
        
{
            StreamReader sr 
= new StreamReader(FILE_PATH, System.Text.Encoding.UTF8);
            
string[] content =new string[5];
            
int i = 0;
            
try
            
{
                
while (sr.Peek() != -1)
                
{
                    i
++;
                    content[i] 
= sr.ReadLine();
                }

            }

            
catch (Exception fileex)
            
{
                MessageBox.Show(
"File Exception:"+fileex.ToString());
            }

            
return content;            
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值