Posts

Showing posts from June, 2014

spFile.OpenBinary() error : file could not be opened

Are you facing this problem while opening the spfile using the url..? SPFile spFile = web.GetFile("/Document Library Name/" + FileName+ ".jpg"); byte[] binFile = spFile.OpenBinary();  <----- error that file could not be opened Here is the solution. Get the SPListItem that contains your file. Use CAML Query to get the list item by passing the column name and its value.     SPList list= web.Lists["Document Library Name"];     SPQuery query = new SPQuery();     query.Query = "<Where><Eq><FieldRef Name=\"" + columnName + "\"/><Value Type=\"Text\">" + value + "</Value></Eq></Where>";     SPListItemCollection itmColl = SPListItemCollection itmcol = list.GetItems(query);     SPFile picture=null;     if (itmcol.Count > 0)      {         picture = itmcol[0].File;         //byte[] binFile = spFile.OpenBinary();      }      byte[] fileData = picture.Op

Creating SharePoint State Machine Workflow

Image
State machine workflow is the powerful feature of SharePoint, which can be easily done using Visual Studio. click here to read my previous tutorial for Creating a SharePoint Sequential Visual Studio Workflow (2 or n Level)   click here to read my previous tutorial on Creating a SharePoint Sequential Visual Studio Workflow (1 Level)   Let me explain how to create a state machine workflow with a example scenario. Scenario : Let's consider a scenario in college. When a student requests for some document with the Administration office , first it goes to an officer, when he approves, it goes to higher officer for approval. When first officer approves, it has to go to next officer and when the 2nd officer approves, the workflow is complete. When first officer rejects, it has to go back to student for re-submission. When first officer approves, and second officer rejects, it has to go back to the first officer for re-approval. Let us create a state machine workflow that mat