?
Solved

Sharepoint Attachment Exceed Size C#

Posted on 2009-05-17
5
Medium Priority
?
653 Views
Last Modified: 2012-05-07
Hi!
I am developing sharepoint webparts and would like to ask a question.

I have an upload control in C# and i have set the file limit in sharepoint adminsitration as 50MB.
When i attempt to upload a 60MB file, the sharepoint site will throw an exception.

Is there any where or idea how i can catch this exception and redirect to our custom error page or stop the upload and inform the user that the file is too large?
0
Comment
Question by:darenceang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 32

Expert Comment

by:Jamie McAllister MVP
ID: 24410007
If you want to monitor the size of the file before upload it can be done with Javascript but it's not pretty;

http://www.kavoir.com/2009/01/check-for-file-size-with-javascript-before-uploading.html
0
 
LVL 4

Author Comment

by:darenceang
ID: 24410367
am unable to run activex on my environment here.
Guess they think its a bigger risk.
Thus, my project dont allow it.

Any more other ways i can do a check without uploading the whole thing over?

I;ve heard someone saying about what packet size headers etc...
0
 
LVL 32

Expert Comment

by:Jamie McAllister MVP
ID: 24410437
I've seen stuff related to packet size headers in PHP, but that doesn't help here! www.phpeasystep.com/phptu/3.html

I guess you're back to capturing the exception and displaying a custom error screen.

Easy way to display an error screen with a custom message is to use;

SPUtility.TransferToErrorPage(message)
0
 
LVL 4

Accepted Solution

by:
darenceang earned 0 total points
ID: 24410515
But doing a try catch can only catch the exception after the WHOLE file is posted upwards?
Is that not?

Sorry... noob
0
 
LVL 32

Expert Comment

by:Jamie McAllister MVP
ID: 24410585
That's right, but alas discounting the javascript/activeX route means we have no way (I'm aware of) of stopping an inappropriate file upload before it happens.

I had a look around for a JQuery method to do this, but it seems to come back to PHP or stuff like this;

http://www.pixeline.be/experiments/jqUploader/

But I'm guessing you can't use that.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question