Пример #1
0
 public static void PrintFile(string filename)
 {
     if (File.Exists(filename))
     {
         try
         {
             DicomFile file = new DicomFile(filename);
             file.Load(DicomReadOptions.DoNotStorePixelDataInDataSet | DicomReadOptions.ReadNonPart10Files);
             StringBuilder sb = new StringBuilder();
             file.Dump(sb, "", DicomDumpOptions.Default);
             Console.WriteLine(sb.ToString());
         }
         catch (Exception)
         {
             Console.WriteLine("Invalid File(Error, maybe not a dicomfile)");
         }
     }
     else
     {
         if (string.IsNullOrWhiteSpace(filename))
         {
             Console.WriteLine("No Filename given");
         }
         else
         {
             Console.WriteLine("Invalid File(File does not exist):" + filename);
         }
     }
 }
Пример #2
0
        public void Go()
        {
            var result = base.Context.DesktopWindow.ShowSaveFileDialogBox(new FileDialogCreationArgs("dump.txt"));

            if (result.Action != DialogBoxAction.Ok)
            {
                return;
            }

            FileInfo info = new FileInfo(result.FileName);

            using (var writeStream = info.OpenWrite())
            {
                using (var writer = new StreamWriter(writeStream))
                {
                    foreach (var path in base.Context.SelectedPaths)
                    {
                        FileProcessor.Process(path, "*.*",
                                              delegate(string file)
                        {
                            try
                            {
                                if (Directory.Exists(file))
                                {
                                    return;
                                }

                                var dicomFile = new DicomFile(file);
                                dicomFile.Load(DicomReadOptions.Default |
                                               DicomReadOptions.DoNotStorePixelDataInDataSet);
                                writer.WriteLine(dicomFile.Dump(String.Empty, DicomDumpOptions.None));
                                writer.WriteLine();
                            }
                            catch (Exception e)
                            {
                                writer.WriteLine("Failed: {0}\n{1}", file, e);
                            }
                        }, true);
                    }
                }
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintCommandLine();
                return;
            }

            if (false == ParseArgs(args))
            {
                return;
            }

            foreach (String filename in args)
            {
                if (filename.StartsWith("-"))
                {
                    continue;
                }

                DicomFile file = new DicomFile(filename);

                DicomReadOptions readOptions = DicomReadOptions.Default;

                try
                {
                    file.Load(readOptions);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Unexpected exception when loading file: {0}", e.Message);
                }

                StringBuilder sb = new StringBuilder();

                file.Dump(sb, "", _options);

                Console.WriteLine(sb.ToString());
            }
        }