Exemplo n.º 1
0
        public void StartSharing()
        {
            try
            {
                //Verify if the shared folder exists
                if (Directory.Exists(_sharedFolder))
                {
                    //Get the list of files found in shared folder
                    string[] sharedFiles = Directory.GetFiles(_sharedFolder);

                    //If folder is not empty
                    if (sharedFiles != null)
                    {
                        string fileName;
                        //Executing a loop through the files
                        foreach (string filePath in sharedFiles)
                        {
                            fileName = Path.GetFileName(filePath);

                            FileSharing file = new FileSharing(fileName, _sharedFolder, _destinationFolder);
                            //Starts the file's sharing process
                            file.StartFileSharingProcess();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void OnChanged(object sender, FileSystemEventArgs e)
        {
            Util.Log(String.Format("FileTypes Created: Path:{0} , Name:{1}; time: {2}", e.FullPath, e.Name, DateTime.Now.ToString()));

            string      fileName = Path.GetFileName(e.FullPath);
            FileSharing file     = new FileSharing(fileName, _sharedFolder, _destinationFolder);

            //Starts the file's sharing process
            file.StartFileSharingProcess();
        }