コード例 #1
0
 public void Unzip(String pathName, string targetPath)
 {
     zipProcess.StartInfo.FileName    = zipFilePath;
     zipProcess.StartInfo.Arguments   = @" e " + pathName + @" -o" + folderPath;
     zipProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
     zipProcess.Start();
     MyServiceLogger.Log("Unziped File" + Path.GetFileName(pathName) + " At: " + DateTime.Now.TimeOfDay.ToString());
 }
コード例 #2
0
        //Main function for Moving Files and other things
        public static void testingAndMoving(string pathName)
        {
            if (File.Exists(pathName))
            {
                fileName      = Path.GetFileName(pathName);
                fileExt       = Path.GetExtension(pathName);
                fileFullPath  = Path.GetFullPath(pathName);
                directoryPath = Path.GetDirectoryName(pathName);

                destinationPath = findAndMoveTo(fileExt);

                MyServiceLogger.Log("Moved " + fileName + "to " + destinationPath + " At: " + DateTime.Now.TimeOfDay.ToString());
            }
            else
            {
                MyServiceLogger.Log("File Does Not Exist " + DateTime.Now.TimeOfDay.ToString());
            }
        }
コード例 #3
0
        //Function to check file extension and move a file elsewhere depending on it's extension Name
        protected static string findAndMoveTo(string fileExtension)
        {
            bool     attemptingMoveFile = true;
            string   returnString       = "";
            string   destinationPath    = "";
            FileInfo FI = new FileInfo(fileFullPath);

            while (attemptingMoveFile)
            {
                if (!isFileLocked(FI))
                {
                    try
                    {
                        switch (fileExtension)
                        {
                        case ".txt":
                            destinationPath = testFilePath;
                            returnString    = testFilePath;
                            checkAndCreateDirectory(destinationPath);
                            moveAndDelete(fileFullPath, destinationPath + fileName);
                            attemptingMoveFile = false;
                            break;

                        case ".iso":
                            destinationPath = gamePath;
                            returnString    = gamePath;
                            checkAndCreateDirectory(destinationPath);
                            moveAndDelete(fileFullPath, destinationPath + fileName);
                            attemptingMoveFile = false;
                            break;

                        case ".wbfs":
                            returnString    = gamePath;
                            destinationPath = gamePath;
                            checkAndCreateDirectory(destinationPath);
                            moveAndDelete(fileFullPath, destinationPath + fileName);
                            attemptingMoveFile = false;
                            break;

                        case ".mp4":
                            returnString    = videoPath;
                            destinationPath = videoPath;
                            checkAndCreateDirectory(destinationPath);
                            moveAndDelete(fileFullPath, destinationPath + fileName);
                            attemptingMoveFile = false;
                            break;

                        case ".flv":
                            returnString    = videoPath;
                            destinationPath = videoPath;
                            checkAndCreateDirectory(destinationPath);
                            moveAndDelete(fileFullPath, destinationPath + fileName);
                            attemptingMoveFile = false;
                            break;

                        case ".7z":
                            unZip(fileFullPath, directoryPath);
                            checkAndCreateDirectory(destinationPath);
                            returnString       = "File was Zipped Ergo Unzipped";
                            attemptingMoveFile = false;
                            break;

                        default:
                            destinationPath = testFilePath;
                            returnString    = "Case Went to Default";
                            checkAndCreateDirectory(destinationPath);
                            moveAndDelete(fileFullPath, destinationPath + fileName);
                            attemptingMoveFile = false;
                            break;
                        }
                        return(returnString);
                    }
                    catch (Exception e)
                    {
                        MyServiceLogger.Log(e.ToString() + DateTime.Now.ToString());
                        return(returnString);
                    }
                }
                else
                {
                    return(returnString);
                }
            }
            return(returnString);
        }