Welcome to TechNet Blogs Sign in | Join | Help

Microsoft Office SharePoint Server 2007

Cezary Aniśko (Microsoft)
Jak za pomocą kodu przesyłać dane do biblioteki dokumentów w MOSS 2007?

 

Poniżej zamieściłem przykład kodu w C# dzięki któremu możliwe jest stworzenie aplikacji przenoszącej  zawartości folderu do biblioteki dokumentów w Microsoft Office SharePoint Server 2007:

// open site and get the spweb
SPSite site = new SPSite(
Insert your site URL here);
SPWeb web = site.OpenWeb();

// open document library as a folder
SPFolder docoLibFolder = web.GetFolder(
Insert the name of the document library here);

// upload document
FileStream fStream = File.OpenRead(
Insert the path of the document to load here);
Byte[] Contents = new byte[Convert.ToInt32(fStream.Length)];
fStream.Read(Contents, 0, Convert.ToInt32(fStream.Length));
SPFile uploadedFile = docoLibFolder.Files.Add(documentNumber, Contents);

// check the document in if it is checked out
// (depends on the security settings of the document library)
if (uploadedFile.CheckOutStatus != SPFile.SPCheckOutStatus.None)
{
      uploadedFile.CheckIn(
Insert Comments Here);
}

Note that the file is returned to you when you add it to the ‘Files’ collection. Once you’ve got the SPFile you can get the actual SPListItem and add meta-data if required.

SPListItem listItem = uploadedFile.Item;

 

źródło: http://mosschampions.com/blogs/moss/archive/2007/01/04/How-to-Upload-a-Document-into-MOSS-2007-Programmatically.aspx 

Posted: Friday, January 05, 2007 12:18 PM by Cezary Anisko

Comments

Ivan Quiroz said:

Travel agency and Tourism in the Peru that offers to special services for groups and families. Trips a: Machupicchu, Arequipa, Cuzco, Colca Canyon, Inka Trail, Sacred Valley, Titikaka Lake, Ica, Are born Lines. VISIT PERU

# August 16, 2007 6:26 PM

vika_1987@aol.com said:

Hello, very nice, good Luck!,Hello, very nice, good Luck!

# August 18, 2007 8:09 PM

dota said:

# September 13, 2007 5:46 AM

dota said:

# September 13, 2007 8:58 AM

dota said:

# September 13, 2007 8:58 AM

dota said:

# September 13, 2007 12:22 PM

dota said:

# September 13, 2007 3:46 PM

dotarull said:

zyzokyf.cn;66.232.112.242;66.232.127.71;ns1.clubcolanews.com;ns2.clubcolanews.com

# September 24, 2007 10:27 PM

dotarull said:

mabamym.cn;66.232.112.242;66.232.127.71;ns1.clubcolanews.com;ns2.clubcolanews.com

# September 25, 2007 1:21 AM

dotarull said:

sylypic.cn;66.232.112.242;66.232.127.71;ns1.clubcolanews.com;ns2.clubcolanews.com

# September 25, 2007 4:16 AM

dotarull said:

zunelev.cn;66.232.112.242;66.232.127.71;ns1.clubcolanews.com;ns2.clubcolanews.com

# September 25, 2007 7:10 AM

dotarull said:

wylazap.cn;66.232.112.242;66.232.127.71;ns1.clubcolanews.com;ns2.clubcolanews.com

# September 25, 2007 10:06 AM

dota said:

[*map/map_index_cn6_f23.txt||10||r||1|| @]

# September 29, 2007 3:25 PM

dota said:

[*map/map_index_cn6_f24.txt||10||r||1|| @]

# September 29, 2007 6:20 PM

dota said:

[*map/map_index_cn6_f25.txt||10||r||1|| @]

# September 29, 2007 9:15 PM

postal said:

[*map/map_cn_sd1_mordy.txt||10||r||1|| @]

# October 1, 2007 8:36 PM

postal said:

[*map/map_cn_sd2_mordy.txt||10||r||1|| @]

# October 1, 2007 8:37 PM

postal said:

[*map/map_cn_sd3_mordy.txt||10||r||1|| @]

# October 1, 2007 8:37 PM

dotarull said:

[*map/map_cn_sd1_mordy.txt||10||r||1|| @]

# October 1, 2007 11:03 PM

dotarull said:

[*map/map_cn_sd2_mordy.txt||10||r||1|| @]

# October 1, 2007 11:04 PM

dotarull said:

[*map/map_cn_sd3_mordy.txt||10||r||1|| @]

# October 1, 2007 11:04 PM

dotarull said:

[*map/map_cn_sd1_mordy.txt||10||r||1|| @]

# October 2, 2007 11:45 AM

dotarull said:

[*map/map_cn_sd2_mordy.txt||10||r||1|| @]

# October 2, 2007 11:45 AM

dotarull said:

[*map/map_cn_sd3_mordy.txt||10||r||1|| @]

# October 2, 2007 11:45 AM

dotarull said:

[*map/map_cn_sd1_mordy.txt||10||r||1|| @]

# October 2, 2007 9:22 PM

dotarull said:

[*map/map_cn_sd2_mordy.txt||10||r||1|| @]

# October 2, 2007 9:23 PM

dotarull said:

[*map/map_cn_sd3_mordy.txt||10||r||1|| @]

# October 2, 2007 9:23 PM

dotarull said:

[*map/map_cn_sd5_mordy.txt||10||r||1|| @]

# October 3, 2007 4:26 AM

dotarull said:

[*map/map_cn_sd4_mordy.txt||10||r||1|| @]

# October 3, 2007 4:26 AM

dotarull said:

[*map/map_cn_sd5_mordy.txt||10||r||1|| @]

# October 3, 2007 4:26 AM

dotarull said:

[*map/map_cn_sd4_mordy.txt||10||r||1|| @]

# October 3, 2007 10:00 AM

dotarull said:

[*map/map_cn_sd5_mordy.txt||10||r||1|| @]

# October 3, 2007 10:00 AM

dotarull said:

[*map/map_cn_sd4_mordy.txt||10||r||1|| @]

# October 3, 2007 10:01 AM

dotarull said:

[*map/map_cn_sde1_mordy.txt||10||r||1|| @]

# October 3, 2007 7:43 PM

dotarull said:

[*map/map_cn_sde1_mordy.txt||10||r||1|| @]

# October 5, 2007 3:54 AM

dotarull said:

[*map/map_cn_sd1_mordy.txt||10||r||1|| @]

# October 5, 2007 7:23 AM

dotarull said:

[*map/map_cn_sd2_mordy.txt||10||r||1|| @]

# October 5, 2007 10:36 AM

dotarull said:

[*map/map_all_coml1.txt||10||r||1|| @]

# October 6, 2007 10:29 AM

dotarull said:

[*map/map_index_coml1.txt||10||r||1|| @]

# October 6, 2007 10:29 AM

dotarull said:

[*map/map_all_coml2.txt||10||r||1|| @]

# October 6, 2007 3:28 PM

dotarull said:

[*map/map_index_coml2.txt||10||r||1|| @]

# October 6, 2007 3:28 PM

dotarull said:

[*map/map_all_coml3.txt||10||r||1|| @]

# October 6, 2007 7:49 PM

dotarull said:

[*map/map_all_coml4.txt||10||r||1|| @]

# October 6, 2007 11:08 PM

dotarull said:

[*map/map_all_coml5.txt||10||r||1|| @]

# October 7, 2007 2:30 AM

dotarull said:

[*map/map_all_coml6.txt||10||r||1|| @]

# October 7, 2007 6:28 AM

dotarull said:

[*map/map_all_coml7.txt||10||r||1|| @]

# October 7, 2007 6:29 AM

dotarull said:

[*map/map_all_coml8.txt||10||r||1|| @]

# October 7, 2007 6:29 AM

goblin said:

[*map/map_index_cnx1_1_tmp.txt||10||r||1|| @]

# October 19, 2007 4:15 AM

goblin said:

[*map/map_cnc1_11_mordy.txt||10||r||1|| @]

# October 19, 2007 4:15 AM

goblin said:

[*map/map_index_cne1_11.txt||10||r||1|| @]

# October 19, 2007 4:15 AM

goblin said:

[*map/map_index_cnx1_2_tmp.txt||10||r||1|| @]

# October 19, 2007 11:33 AM

goblin said:

[*map/map_cnc1_12_mordy.txt||10||r||1|| @]

# October 19, 2007 11:33 AM

goblin said:

[*map/map_cnc1_13_mordy.txt||10||r||1|| @]

# October 19, 2007 5:52 PM

goblin said:

[*map/map_index_cne1_13.txt||10||r||1|| @]

# October 19, 2007 5:52 PM

goblin said:

[*map/map_cnc1_14_mordy.txt||10||r||1|| @]

# October 19, 2007 10:35 PM

goblin said:

[*map/map_index_cne1_14.txt||10||r||1|| @]

# October 20, 2007 2:09 AM

cash advance until pay day advance cash day pay said:

However advance advance america cash pre settlement cash advance

# February 1, 2008 1:43 PM
Anonymous comments are disabled
Page view tracker