Thursday, April 18, 2013

[SharePoint] Upload File To Document Library Using SharePoint Object Model - Authenticate or Anonymous Access



using Microsoft.SharePoint;    //SharePoint
using System.IO;                //Stream

//if  Anonymous Access, document library must set to allow anonymous to add items
string strSharePointURL = "http://www.sharepoint.com";

if (txtUpload.HasFile)
{
    if (txtUpload.PostedFile.ContentLength > 0)
    {
        //string strFileName = txtUpload.PostedFile.FileName;
        string strFileName = txtUpload.FileName;

        Stream fStream = txtUpload.PostedFile.InputStream;
        byte[] bStream = new byte[fStream.Length];
        fStream.Read(bStream, 0, bStream.Length);
        fStream.Close();

        SPSecurity.RunWithElevatedPrivileges(delegate()
        {
            using (SPSite objSite = new SPSite(strSharePointURL))
            {
                using (SPWeb objWeb = objSite.OpenWeb())
                {
                    SPFolder libraryFolder = objWeb.Folders["Document_Library_Name"];
                    objWeb.AllowUnsafeUpdates = true;

                    libraryFolder.Files.Add(strFileName, bStream, true);
                }
            }
        });
    }
}
//In html code
<asp:FileUpload runat="server" id="txtUpload"/>

Monday, April 15, 2013

[SQL] Get Date Only - Date Only No Time

DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)

Sunday, April 14, 2013

[MAC]: How To Burn ISO Disc Images

  1. Insert a blank disc.
  2. Start Disk Utility.
    • BY: Finder -> Applications -> Utilities -> Disk Utility
    • OR: LauchPad -> Other -> Disk Utility
  3. From the File menu, choose Open Disk Image and select the ISO to be burned.
  4. In the list of volumes, you will now see an item representing the ISO file. Select it.
  5. Click the Burn button and follow the instructions.