private FileInfo toFile(Dataset ds) { String studyInstUID = null; try { studyInstUID = ds.GetString(Tags.StudyInstanceUID); if (studyInstUID == null) { throw new DcmServiceException(MISSING_UID, "Missing Study Instance UID"); } if (ds.vm(Tags.SeriesInstanceUID) <= 0) { throw new DcmServiceException(MISSING_UID, "Missing Series Instance UID"); } String instUID = ds.GetString(Tags.SOPInstanceUID); if (instUID == null) { throw new DcmServiceException(MISSING_UID, "Missing SOP Instance UID"); } String classUID = ds.GetString(Tags.SOPClassUID); if (classUID == null) { throw new DcmServiceException(MISSING_UID, "Missing SOP Class UID"); } if (!instUID.Equals(ds.GetFileMetaInfo().MediaStorageSOPInstanceUID)) { throw new DcmServiceException(MISMATCH_UID, "SOP Instance UID in Dataset differs from Affected SOP Instance UID"); } if (!classUID.Equals(ds.GetFileMetaInfo().MediaStorageSOPClassUID)) { throw new DcmServiceException(MISMATCH_UID, "SOP Class UID in Dataset differs from Affected SOP Class UID"); } } catch (DcmValueException e) { throw new DcmServiceException(CANNOT_UNDERSTAND, e); } String pn = ToFileID(ds, Tags.PatientName) + "____"; FileInfo dir = archiveDir; for (int i = 0; i < dirSplitLevel; ++i) { dir = new FileInfo(dir.FullName + "\\" + pn.Substring(0, (i + 1) - (0))); } dir = new FileInfo(dir.FullName + "\\" + studyInstUID); dir = new FileInfo(dir.FullName + "\\" + ToFileID(ds, Tags.SeriesNumber)); FileInfo file = new FileInfo(dir.FullName + "\\" + ToFileID(ds, Tags.InstanceNumber) + ".dcm"); return file; }