Пример #1
0
        private void ProcessFile(string vb6ProjectFolder, VBNetProjectFileWriter vbNetWriter, VB6SourceFile codeFile)
        {
            var fileToConvert = Path.Combine(vb6ProjectFolder, codeFile.SourceFileName);

            if (File.Exists(fileToConvert))
            {
                var dotNetFileName = Path.Combine(vbNetWriter.ProjectFolder, Path.GetFileNameWithoutExtension(codeFile.SourceFileName) + ".vb");
                ConvertCodeFile(codeFile, fileToConvert, dotNetFileName);
            }
            else
            {
                throw new Exception($"VB6 code file not found: {codeFile.SourceFileName}");
            }
        }
Пример #2
0
        public void Convert(string vb6ProjectFilePath, string dotNetFolderPath)
        {
            string originalWorkingDirectory = string.Empty;

            try
            {
                originalWorkingDirectory = Directory.GetCurrentDirectory();

                // Extract data from VB6 project file and convert it to .net project file.
                var projectParser = new VisualBasic6ProjectParser();
                var vb6Project    = projectParser.ParseProjectFile(vb6ProjectFilePath);
                var vbNetProject  = new VBNetProject(vb6Project);
                var vbNetWriter   = new VBNetProjectFileWriter(vbNetProject, originalWorkingDirectory, dotNetFolderPath);
                vbNetWriter.CreateProjectFile();

                var vb6ProjectFolder = Path.GetDirectoryName(vb6ProjectFilePath);
                foreach (var md in vb6Project.ProjectModules)
                {
                    ProcessFile(vb6ProjectFolder, vbNetWriter, md);
                }

                foreach (var cls in vb6Project.ProjectClasses)
                {
                    ProcessFile(vb6ProjectFolder, vbNetWriter, cls);
                }
            }
            catch (Exception ex)
            {
                // Debugging purposes...
                throw;
            }
            //finally
            //{
            //    if (!string.IsNullOrWhiteSpace(originalWorkingDirectory))
            //        Directory.SetCurrentDirectory(originalWorkingDirectory);
            //}
        }