1: public partial class Form1 : Form
2:
3: { 4:
5: public Form1()
6:
7: { 8:
9: InitializeComponent();
10:
11: }
12:
13:
14:
15: public static void GetDocuments(string StartDirectory, string OutputDirecotry)
16:
17: { 18:
19: List<System.IO.FileInfo> Files = Utilities.FileManager.FileList(StartDirectory);
20:
21: List<System.IO.DirectoryInfo> Directories = Utilities.FileManager.DirectoryList(StartDirectory);
22:
23: foreach (System.IO.FileInfo File in Files)
24:
25: { 26:
27: if (File.Extension.Equals(".nsf", StringComparison.CurrentCultureIgnoreCase)) 28:
29: { 30:
31: if (File.Name.Equals("Main.nsf")) 32:
33: { 34:
35: GetFromNSFdb(File.FullName, OutputDirecotry);
36:
37: }
38:
39: else
40:
41: { 42:
43: Utilities.FileManager.CreateDirectory(OutputDirecotry + "/" + File.Name.Replace(".nsf","")); 44:
45: GetFromNSFdb(File.FullName, OutputDirecotry);
46:
47: }
48:
49: }
50:
51: }
52:
53: foreach (System.IO.DirectoryInfo Directory in Directories)
54:
55: { 56:
57: if (!Directory.Name.Equals("Search.ft", StringComparison.CurrentCultureIgnoreCase)) 58:
59: { 60:
61: Utilities.FileManager.CreateDirectory(OutputDirecotry + "/" + Directory.Name);
62:
63: GetDocuments(Directory.FullName, OutputDirecotry + "/" + Directory.Name);
64:
65: }
66:
67: }
68:
69: }
70:
71:
72:
73: public static void GetFromNSFdb(string strNSFdbName,string OutputDirectory)
74:
75: { 76:
77:
78:
79: try
80:
81: { 82:
83: Domino.ISession session = new NotesSessionClass();
84:
85: session.Initialize(""); 86:
87: Domino.NotesDatabase database = session.GetDatabase("", strNSFdbName, false); 88:
89: Domino.NotesNoteCollection noteCollecton = database.CreateNoteCollection(true);
90:
91: noteCollecton.SelectDocuments = true;
92:
93: noteCollecton.BuildCollection();
94:
95: string NextDoc = noteCollecton.GetFirstNoteId();
96:
97: while (!string.IsNullOrEmpty(NextDoc))
98:
99: { 100:
101: Domino.NotesDocumentClass TempDoc = (Domino.NotesDocumentClass)database.GetDocumentByID(NextDoc);
102:
103: if (TempDoc.HasEmbedded)
104:
105: { 106:
107: object[] items = (object[])TempDoc.Items;
108:
109: foreach (NotesItem item in items)
110:
111: { 112:
113: if (item.Name.Equals("$FILE")) 114:
115: { 116:
117: object[] values = (object[])item.Values;
118:
119: TempDoc.GetAttachment(values[0].ToString()).ExtractFile(OutputDirectory + "/" + values[0].ToString());
120:
121: }
122:
123: }
124:
125: }
126:
127: NextDoc = noteCollecton.GetNextNoteId(NextDoc);
128:
129: }
130:
131: }
132:
133: catch { } 134:
135: }
136:
137:
138:
139: private void button1_Click(object sender, EventArgs e)
140:
141: { 142:
143: GetDocuments(textBox1.Text, textBox2.Text);
144:
145: MessageBox.Show("Done"); 146:
147: }
148:
149:
150:
151: private void textBox1_Click(object sender, EventArgs e)
152:
153: { 154:
155: folderBrowserDialog1.ShowNewFolderButton = false;
156:
157: if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
158:
159: { 160:
161: textBox1.Text = folderBrowserDialog1.SelectedPath;
162:
163: }
164:
165: }
166:
167:
168:
169: private void textBox2_Click(object sender, EventArgs e)
170:
171: { 172:
173: folderBrowserDialog1.ShowNewFolderButton = true;
174:
175: if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
176:
177: { 178:
179: textBox2.Text = folderBrowserDialog1.SelectedPath;
180:
181: }
182:
183: }
184:
185: }