コード例 #1
0
        public static void OrganizeFileOnDisk(VCFileWrapper file)
        {
            string root = file.ContainingProject.GetProjectRoot();

            if (root == null)
            {
                throw new InvalidOperationException("project root not set");
            }

            string filePath = PathHelper.GetAbsolutePath(root, file.FilterPath);

            if (filePath == file.FullPath)
            {
                return;
            }

            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                File.Move(file.FullPath, filePath);

                ContainerWrapper parent = file.Parent;
                file.Remove();
                parent.AddFile(filePath);
            }
            catch (Exception e)
            {
                MessageBox.Show("Could not move file: " + e.Message, "VC File Utilities", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        public static VCFileWrapper ReAddFile(VCFileWrapper file)
        {
            ContainerWrapper parent = file.Parent;
            string           path   = file.FullPath;

            file.Remove();
            return(parent.AddFile(path));
        }