0

I'm writing the code to make a popup, and once the user finishes wrting the content and title, it will make a .aspx file and upload to documentary library.

But how can I do that? I googled but there are not many materials on that!

Can anyone help?

5
  • 1
    What do you mean "it will make a .aspx file"? Your site is generating new ASP.NET files? That doesn't seem right. Commented Jul 27, 2012 at 18:00
  • What do you know of SharePoint? Made any development in the past? Commented Jul 30, 2012 at 7:12
  • First, I'm just a rookie I wanna modify a .aspx template and copy to create a new file in the same library, I googled it, but no much showed up Anybody can help? Either link or code will be very very helpful! Commented Jul 31, 2012 at 15:13
  • I hope I made myself understood right? Commented Jul 31, 2012 at 15:13
  • Based on your question, you seem to be describing what can be accomplished using out of the box publishing or wiki pages. If that is not the case, please specify in your question how your situation is different. Commented Aug 1, 2012 at 15:18

1 Answer 1

1

You need to use 'Client Object Model'. you can see (http://www.codeproject.com/Articles/268193/SharePoint-2010-Client-Object-Model-Part-1) for basic understanding of client object model. code which you need to create file in library is:

 String fileToUpload = @"C:\YourFile.txt";
        String sharePointSite = "http://yoursite.com/sites/Research/";
        String documentLibraryName = "Shared Documents";

        using (SPSite oSite = new SPSite(sharePointSite))
        {
            using (SPWeb oWeb = oSite.OpenWeb())
            {
                if (!System.IO.File.Exists(fileToUpload))
                    throw new FileNotFoundException("File not found.", fileToUpload);                    

                SPFolder myLibrary = oWeb.Folders[documentLibraryName];

                // Prepare to upload
                Boolean replaceExistingFiles = true;
                String fileName = System.IO.Path.GetFileName(fileToUpload);
                FileStream fileStream = File.OpenRead(fileToUpload);

                // Upload document
                SPFile spfile = myLibrary.Files.Add(fileName, fileStream, replaceExistingFiles);

                // Commit 
                myLibrary.Update();
            }
        }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.