Exemplo n.º 1
0
        protected override bool RunCommand()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            string message      = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName);
            string fullFilePath = string.Empty;

            string selectedDir = GetSelectedItemDirectory(ref fullFilePath);

            if (!string.IsNullOrEmpty(selectedDir))
            {
                //since 2.0.8
                if (!FileTools.FileExists(selectedDir))
                {
                    ShowMessageBox("The directory or file does not exist");
                    return(false);
                }
                if (!Directory.Exists(selectedDir))
                {
                    selectedDir = Path.GetDirectoryName(selectedDir);
                }
                if (!Directory.Exists(selectedDir))
                {
                    ShowMessageBox("The directory does not exist");
                    return(false);
                }


                OpenCommandPrompt(selectedDir);
            }
            return(true);
        }
Exemplo n.º 2
0
 public CompressTask(CommandCore commandCore, CancellationTokenSource cancelTokenSrc = null)
     : base(commandCore, cancelTokenSrc)
 {
     if (!FileTools.FileExists(selectedFullFilePath))
     {
         selectedFullFilePath = commandCore.GetTopmostRoot();
     }
     arrItems = _commandCore.GetSelectedItems(true);
 }
Exemplo n.º 3
0
        public static bool DeleteFile(string archiveName, ref string errorMessage)
        {
            string fileName = archiveName;

            fileName.TrimStart('"');
            fileName.TrimEnd('"');
            string quotedName = "";

            quotedName = Path.GetPathRoot("K:\\codercrest\\New folder\\New Text Document.txt");
//            FileInfo fi = new FileInfo("K:\\codercrest\\New folder\\New Text Document.txt");
//            quotedName = fi.FullName;

            QuoteString(fileName, ref quotedName);
            FileTools.FileExists(quotedName);
            try
            {
                if (!File.Exists(fileName))
                {
                    return(true);
                }
            }
            catch
            {
            }
            try
            {
                System.Diagnostics.Process p         = new System.Diagnostics.Process();
                ProcessStartInfo           StartInfo = new ProcessStartInfo("cmd.exe");
                StartInfo.Arguments      = String.Format("/C del /F /Q {0}", fileName);
                StartInfo.CreateNoWindow = true;
                //p.StartInfo.FileName = "cmd.exe";
                //p.StartInfo.Arguments = String.Format(" del /F /Q {0}", fileName);
                //p.StartInfo.WorkingDirectory = @Path.GetDirectoryName(archiveName);
                StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                //StartInfo.UseShellExecute = false;

                /*
                 * StartInfo.RedirectStandardOutput = true;
                 * StartInfo.RedirectStandardInput = true;
                 */
                p.StartInfo = StartInfo;
                p.Start();
                p.WaitForExit();
            }
            catch (Exception eProcess)
            {
                if (errorMessage != null)
                {
                    errorMessage = eProcess.Message;
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        public static void AddToList(IVsHierarchy hierarchy, uint itemId, ref List <VSITEMEX> hierList)
        {
            int    result;
            object value         = null;
            string name          = "";
            string canonicalName = null;

            if (hierarchy != null)
            {
                result = hierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_Name, out value);

                if (result == VSConstants.S_OK && value != null)
                {
                    name = value.ToString();
                }

                result = hierarchy.GetCanonicalName(itemId, out canonicalName);
                if (result == VSConstants.S_OK)
                {
                }
                if (string.IsNullOrEmpty(canonicalName))
                {
                    return;
                }
                if (!FileTools.FileExists(canonicalName))
                {
                    return;
                }
                IVsProject vsProject = hierarchy as IVsProject;
                if (vsProject != null)
                {
                    hierList.Add(new VSPROJECTEX(vsProject, itemId, canonicalName));
                }
                else
                {
                    hierList.Add(new VSITEMEX(hierarchy, itemId, canonicalName));
                }
            }
        }