예제 #1
0
        public static void Add(Project destination, ProjectItem projectItem)
        {
            if (!_relativeFilenames.Select(m => m.Name).Contains(projectItem.FilenameAsRelativePath()))
            {
                _relativeFilenames.Add(new RelativeFile(projectItem.FilenameAsRelativePath()));
            }

            var saveTo = destination.Combine(projectItem.FilenameAsRelativePath());

            Directory.CreateDirectory(Path.GetDirectoryName(saveTo));

            if (File.Exists(saveTo))
            {
                File.Delete(saveTo);
            }

            File.Copy(projectItem.FileNames[0], saveTo, true);
            if (File.GetAttributes(saveTo).HasFlag(FileAttributes.ReadOnly))
            {
                File.SetAttributes(saveTo, File.GetAttributes(saveTo) & ~FileAttributes.ReadOnly);
            }

            OutputWindow.Log(String.Format("Suctioning '{0}'", saveTo));
        }