Beispiel #1
0
        public static long GetFileLength(string file)
        {
            TSysConfig sysConfig = new TSysConfig();
            string path = sysConfig.GetIniString("path", "-1");
            if (path == "-1")
            {
                MessageBox.Show("没有从系统配置文件中找到目录");
                return 0;
            }

            string fileName = Path.Combine(path, file);
            FileStream s = null;
            try
            {
                s = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                return s.Length;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return 0;
            }
            finally
            {
                if (s != null)
                    s.Close();
            }
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            _sysConfig = new TSysConfig();
            _port = _sysConfig.GetIniInt("Port", 9999);

            Thread t = new Thread(new ThreadStart(WaitForConnect));
            t.IsBackground = true;
            t.Start();
        }
Beispiel #3
0
        public static TCommand GetFileListCommand()
        {
            TSysConfig sysConfig = new TSysConfig();
            string path = sysConfig.GetIniString("path", "-1");
            if (path == "-1")
            {
                MessageBox.Show("没有从系统配置文件中找到目录");
                return null;
            }

            string[] files = GetFileList(path);
            TCommand command = new TCommand(CommandStyleEnum.cListReturn);

            foreach (string s in files)
                command.AppendArg(s);

            return command;
        }
Beispiel #4
0
        public static FileStream GetFileStream(string file)
        {
            TSysConfig sysConfig = new TSysConfig();
            string path = sysConfig.GetIniString("path", "-1");
            if (path == "-1")
            {
                MessageBox.Show("没有从系统配置文件中找到目录");
                return null;
            }

            string fileName = Path.Combine(path, file);

            FileStream s = null;
            try
            {
                s = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                return s;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return null;
            }
        }
Beispiel #5
0
 private void Form1_Load(object sender, EventArgs e)
 {
     _sysConfig = new TSysConfig();
     _port = _sysConfig.GetIniInt("ServerPort", 9999);
     _server = _sysConfig.GetIniString("ServerAddress", "ie");
 }