Hi,
First, sorry for posting so much topics :/
As I said in the subject, I want to copy a document from one sharepoint library to another one. I planned to use two sharepoint document events, one for getting the last version (copy) and one for uploading a document (paste). Is it correct?
Then if I try this, I set the first event to get the document and copy it to a specified directory (c: ) with a specified name (temp). The compilation works fine.
Then I set the upload document event to get this file (c: emp) for uploading it but when I compiled, I get an error:
The type or namespace "File" could not be found
But I used only the wizards... if I go through code, I can't find effectively the declaration of File but it is used in the code.
Page 1 / 1
How do you specify the name of the document when saving it to C:Temp?
Does that include or exclude the file extension?
My guess with this one is that you have the file name not specified correctly in the second step, the common mistake is normally with the file extension.
Does that include or exclude the file extension?
My guess with this one is that you have the file name not specified correctly in the second step, the common mistake is normally with the file extension.
OK,
In fact I put "c:" as the folder and "temp" as the filename, so without any extension...
I will try to put extension
In fact I put "c:" as the folder and "temp" as the filename, so without any extension...
I will try to put extension
Ok, it's work better but it's still not usable.. I get an error message logged in K2 Console:
The path specified is being used in a substitute.
Here is the code:
public void Main(ref ServerEventContext K2)
{
// Set up variables
string Temp, ErrorMessage = "";
string Server;
Server = "http://cmfrap002dev";
if (! (Server.EndsWith("/") )) Server += "/";
object tempSite;
string Site;
tempSite = "personal/Touzard";
Site = tempSite.ToString();
if (! (Site.EndsWith("/") && Site.Trim() != "" )) Site += "/";
object Folder = "";
Folder = "Private Documents";
if (! (Folder.ToString().EndsWith("/") )) Folder += "/";
object File = "";
File = K2.ProcessInstance.DataFields["Title"].Value;
object LocalFolder = "";
LocalFolder = "c:"";
object LocalFile = "";
LocalFile = "temp.doc";
K2SPSList SpsList = new K2SPSList();
// Set Url for Web Service
SpsList.Url = Server + "_vti_bin/K2SpsList.asmx";
// Set Credentials
SourceCode.K2SPUtilities.SPSUtilities SpsUtils = new SourceCode.K2SPUtilities.SPSUtilities();
SpsList.Credentials = SpsUtils.GetCredentials(Server);
byte[] oByte = new byte[1];
// Call Web Service to Download Document
if (! (SpsList.GetDocument(Server, Site, Folder.ToString(),
File.ToString(), ref oByte, ref ErrorMessage))) {
// Error Occurred in GetDocument - Raise Error
throw new System.Exception(ErrorMessage);
}
K2Base64.K2Base64 K2B64 = new K2Base64.K2Base64();
// Build The file path
string LocalFilePath;
if (! (LocalFolder.ToString().EndsWith(""") )) {
LocalFilePath = LocalFolder + """ + LocalFile;
} else {
LocalFilePath = LocalFolder + "" + LocalFile;
}
K2B64.ByteArrayToFile(ref oByte, LocalFilePath.ToString());
}
I'm not friendly enough with english to understand exactly what means this error sentence...
The path specified is being used in a substitute.
Here is the code:
public void Main(ref ServerEventContext K2)
{
// Set up variables
string Temp, ErrorMessage = "";
string Server;
Server = "http://cmfrap002dev";
if (! (Server.EndsWith("/") )) Server += "/";
object tempSite;
string Site;
tempSite = "personal/Touzard";
Site = tempSite.ToString();
if (! (Site.EndsWith("/") && Site.Trim() != "" )) Site += "/";
object Folder = "";
Folder = "Private Documents";
if (! (Folder.ToString().EndsWith("/") )) Folder += "/";
object File = "";
File = K2.ProcessInstance.DataFields["Title"].Value;
object LocalFolder = "";
LocalFolder = "c:"";
object LocalFile = "";
LocalFile = "temp.doc";
K2SPSList SpsList = new K2SPSList();
// Set Url for Web Service
SpsList.Url = Server + "_vti_bin/K2SpsList.asmx";
// Set Credentials
SourceCode.K2SPUtilities.SPSUtilities SpsUtils = new SourceCode.K2SPUtilities.SPSUtilities();
SpsList.Credentials = SpsUtils.GetCredentials(Server);
byte[] oByte = new byte[1];
// Call Web Service to Download Document
if (! (SpsList.GetDocument(Server, Site, Folder.ToString(),
File.ToString(), ref oByte, ref ErrorMessage))) {
// Error Occurred in GetDocument - Raise Error
throw new System.Exception(ErrorMessage);
}
K2Base64.K2Base64 K2B64 = new K2Base64.K2Base64();
// Build The file path
string LocalFilePath;
if (! (LocalFolder.ToString().EndsWith(""") )) {
LocalFilePath = LocalFolder + """ + LocalFile;
} else {
LocalFilePath = LocalFolder + "" + LocalFile;
}
K2B64.ByteArrayToFile(ref oByte, LocalFilePath.ToString());
}
I'm not friendly enough with english to understand exactly what means this error sentence...
In order to move or copy a document from one SharePoint document library to another you have to use the K2.net 2003 SharePoint Multiple Documents event template.
Oh ok, I will test it. Thanks !
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.