MOSS Forum

 
Home » Forum » MOSS       Ask a questionRSS Feeds

Add documents to Sharepoint Document library from another website

  Asked By: Jeramy Livingston         Date: Nov 02, 2009      Category: MOSS      Views: 272
 

I have a custom website in which I am generating a csv file. I want the
file to be saved to a SP document library after the file is creating. My
attempt at this gives me the following error "URI Formats are not supported".

The web server where this website is located does not have SP installed.

Can someone help me tweak my code? Here is what I am currently using:

Protected Sub btnindesign_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnindesign.Click


'Declare variables
Dim profile As String
Dim username As String
Dim Csv As New Exporter()
Dim filename As String
'Dim filename2 As String
Dim filepath As String


'Assign variables
profile = Session("profile")
username = Session("user")
filename = "Resume.csv"


filepath = "http://sharepoint/dsi/preconservices/internal/resumes/" +
username + "/csv/"




'Check for filepath
filepath = filepath + username + "/csv/"
''If no user name folder exists, create a new one
If Directory.Exists(filepath) = False Then
Directory.CreateDirectory(filepath)
End If



If filename.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) = -1
Then

Using CsvWriter As New StreamWriter(filepath)
CsvWriter.Write(Csv.CsvFromDatatable(GetResumeData(username,
profile)))
End Using



End If


End Sub

Tagged:                  

 

3 Answers Found

 
Answer #1       Answered By: Akshara Sanghavi          Answered On: Nov 02, 2009       

Changed my code to the following but it is telling me that the network path is
invalid at the Streamwriter code. I did a breakpoint on this line of code and
it is showing the correct file path to SharePoint.

Protected Sub btnindesign_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnindesign.Click


'Declare variables
Dim profile As String
Dim username As String
Dim Csv As New Exporter()
Dim filename As String
'Dim filename2 As String
Dim filepath As String


'Assign variables
profile = Session("profile")
username = Session("user")
filename = "Resume.csv"


filepath = "\\sharepoint\dsi\preconservices\internal\resumes\" +
username + "\csv"




''Check for filepath
'filepath = filepath + username + "\csv\"
'' ''If no user name folder exists, create a new one
'If Directory.Exists(filepath) = False Then
' Directory.CreateDirectory(filepath)
'End If

'Response.Write(filepath)

If filename.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) = -1
Then

Using CsvWriter As New StreamWriter(filepath)
CsvWriter.Write(Csv.CsvFromDatatable(GetResumeData(username,
profile)))
End Using



End If


End Sub

 
Answer #2       Answered By: Aishwarya Dixit          Answered On: Nov 02, 2009       

That being said, try this link for an example:
tallahasseespeed.com/kristopherbaker/default.aspx

Go down to the ItemAttachmentAdded post...there's something wrong with the
permissions on the site otherwise I would send you directly to the post.

 
Answer #3       Answered By: Indrajeet Patil          Answered On: Nov 02, 2009       

.I'm guessing you are a C# lover...heehee. I actually figured out the
problem. I was missing the line of code that specified the file name. Go
figure!

 


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].