.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to check File(pdf) is Readonly or not?

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
hi all,Is it possible to to check while uploading pdf file that it is read only?if it is possible than how to do that using c#?? please advice..

View Complete Post

More Related Resource Links

The file reached the maximum download limit. Check that the full text of the document can be meaning



I'm facing an issue with the indexing.

I have 1 WFE+Index server+DB server.

Index server is not installed with MS FIlter pack 1.0

When crawling, the there will be document with warning in crawl log:
The file reached the maximum download limit. Check that the full text of the document can be meaningfully crawled.

Documents that with warning are such as doc, ppt, xls, docs, ppts and many others.
However, I view into the successful crawled document, there are doucments with ext doc and ppt.

For large file index, there are MaxGrowthFactor + MaxDownLoadSize required to be added into the index server.

As my understanding is, MS Filter Pack should installed into index server(already did, correct me if i'm wrong).

I looked into the Office SharePoint Seach(CA>Services in farm), if the server is appointed to "Use this server as indexing server", then MS Filter Pack is suppose to be installed into that particular server as well.

At the bottom, there also has another option is "Use all web front end for crawling".

The question here is, IF the option "Use all web front end for crawling" is selected.
Does the WED FRONT END Server required to installed the Ms Filte

How check if file exists?

Hello I want to delete file, i can do this but firstly i want to check if it exist. What must i add to  my code for this? DECLARE @del varchar(50) SET @del = REPLACE(' del C:\ADFS\Data_'+CONVERT(char(10),dateadd(year,+1,DATEADD(dd, -1, GETDATE())),103)+'.csv','/','.') EXEC master..xp_cmdshell @del

how to check one time java script file download not every session

how to check one time java script file download not every session

How do i force SharePoint to open file automatically during check out process?

Currently, when checking out a file (doc., excel, pdf etc.) in Sharepoint, i right click on doc. and click "check out". Then a window pops up and saying " you are about to check out:...." and i choose the option of saving the file in my Local Drafts Folder. The issue is that the file does not open automatically once i click "ok" in pop up window. I have go back to file in SharePoint and click on it again to open it. How do i force SharePoint to automatically open the file, when i go through the check it out process? Thank you all for your feedback.

check file size before uploading process in c# with asp.net


Hi All,

Thank you for Advance.

currently we are configured execution Timeout="1200" (The default is 110 seconds)  and maxRequestLength="12288"  (The default is 4096 KB)

but some times users upload files above 12MB so we are getting "Maximum request length exceeded" error.

we are checking the file size using client side javascript ActiveXObject object. but ActiveXObject only works in IE not in others like mozilla,crome,...

Jacescript Code are

function GetSize(file)
  var fso=new ActiveXObject("Scripting.FileSystemObject");
  var f=fso.getFile(file);
  return fso.getFile(file).size;


how can i check the file size before uploading process with support all the browser.

any posiblities for checking file size before server side script/object?


Im downloading a file and checking internet connection im trying to use event to check when the file


I used breakpoint on the event but its never get there.

This is the code of the connection testing of the internet while downloading the file in the contrustor:

if (fdt.http_test()== true)
                    Client.DownloadFile(remote_image_on_server, temp_dir + temp_file);
                    label6.Enabled = true;
                    label6.Visible = true;
                    label6.Text = "Internet connection active";              

How to check for file exists on remote server in ssrs 2008?

I have a report that needs to display images that are stored on a remote web server. The problem is that I also need to check if the file exists first otherwise I get those annoying image not found red X's.

I tried entering the code at the bottom in the custom code section of the report which works if I run it on my local machine however it doesn't work in SSRS 2008. After doing a little trial and error I found it seems to be failing on the first line in the function,

Dim request = System.Net.WebRequest.Create(New Uri (fileURL))

Is there some specific permissions or configuration change needed on the SSRS2008 server for this code to work? Or is there a better way to do this?


Public Function CheckRemoteURL(ByVal fileURL As String) As String
Dim request = System.Net.WebRequest.Create(New Uri (fileURL))
request.Method = "HEAD"

Dim returnURL = ""

Dim response = request.GetResponse()
returnURL = fileURL
Catch ex As Exception
returnURL =""
End Try

Return returnURL
End Function

CHeck to see if file exists on Server before backup



  I want to check first to see ifthe xyz.bak file exsits before I perform a backup.



Check file permission in (local/network share) directory?



I need to check whether a user has read/write permission to a file on any directories (local or network share).

Can someone provide a short code sample?

I've seen many examples online (pinvoking NetShareGetInfo, DirectoryInfo.GetAccessControl(), FileIOPermission.Demand(), etc), but I'm still unable to correctly check if a file in a network share directory (e.g, \\networkPC\sharedFolder) is readable/writable.

All my checks will pass, but when I attempt to write a file, I get UnauthorizedAccessException ("Access to the path ... is denied").

Should I really be doing my checks this way?

public static bool IsFileWritable(string fileName)
  bool isWritable;
  FileInfo file = new FileInfo(fileName);
    using (Stream stream = file.OpenWrite()) // attempt to open a write stream.
    isWritable = true;
    isWritable = false;

Check if file exists


In SSIS, I need an easy way to see if a file exists, and if not wait for it until a timeout period expires.  Here are the options I've discovered, along with the issues I've had:

a) The File Watcher task from www.sqlis.com

This was my first attempt.  The task works great, BUT only detects when there is a change on the file.  If the file already exists, it keeps waiting which is not the behavior I need.

b) The WMI Event Task

There is very sparce documentation on this event and how to write a WQL query.  There are numerous examples of monitoring a folder and if any files appear, cause an event to happen.  I need to detect for a specific file.  I found maybe one example of this using "PartComponent" but wasn't able to get the sytax right to make it work for me.  I also need to access a remote file share using a UNC path (e.g. \\servername\path\file.txt) which I could not get to work.

c) Script Task using the File.Exists() method

I imported the System.IO namespace, and used a File.Exists(

check if file exists inside foreach container?


Hi All,

I have a foreach container that checks a folder C:\FTP for an Excel file named Fast_<date>.xls, imports the data, and copies the file to C:\Archive.

I need to add a step that checks C:\Archive for a file with the same name as the file in C:\FTP before the import step.  If the file is already present in C:\Archive, the package should fail.  If it isn't, then it should continue normally.

I found a promising-looking link in a previous post, but the referenced page no longer exists (below).   I have never used a script task, and I will have a different file name each time, so I am a little confused. 

If someone's feeling benevolent, suggestions would be very much appreciated!!

Thanks in advance!

broken link: http://agilebi.com/cs/blogs/jwelch/archive/2007/10/31/checking-for-the-existence-of-a-file.aspx


"Object reference not set to an instance of an object" when 1 single user tries to check out a file


We are running WSS 3.0 SP2.  We have 1 single user that started having the following occur:  When he goes into a document library in which he has contribute permissions, selects a file, picks Check Out and Edit, he is getting a pop-up stating 'Object reference not set to an instance of an object".  When he clicks on the OK button he gets another message stating that it may be a permission issue or the file may be locked for editing by another user.

I have confirmed that nobody else has the file checked out for editing.  Other users (including myself) can open the exact same files, check them out and edit them, then check them back in.

I have searched the web for this error and have not found anything useful to tell me what to try on his machine.  I’m thinking it is a local PC issue since he is the only one experiencing the issue plus I have had him log into our Citrix client and he can successfully check out and edit files there.  He has done a reboot of his machine but this did not res

How to check for existing node while writing in XML file ?



         I have to add a node each time the compiler passes through the following code :

         string XMLFilePath = System.Web.Hosting.HostingEnvironment.MapPath("~/Log/log.xml").ToString();

            if (File.Exists(XMLFilePath))
                XmlTextWriter xmlWriter = new XmlTextWriter(XMLFilePath, System.Text.Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                xmlWriter.WriteElementString("error", "No file input");

View State Error when user tries to check in file


Recently we encounter issue with SharePoint 2007 that the user is unable to check in file. Whenever user try to check in file, it will show error page: 


Invalid viewstate.
Client IP: [IP Address]
Port: 58105
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)
ViewState: /wEWCQKOxPCTDQKPztqIBgKpn5bCCwLEiLTXBQKa/+iZBQKN/6CDBgKW/PDbDwLNrvW5AwLbqef0C9c8RUbYCyi0Rc58jgXqG3fOpsYC
Referer: [path]/Forms/AllItems.aspx
Path: /_layouts/Checkin.aspx


Any idea?? Thank you.

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

File Splitter in .Net

I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net Basics on File operations
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend