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

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

How check if file exists?

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :Sql Server
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

View Complete Post

More Related Resource Links

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 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


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

Is there a way to check if workflow instance already exists for a particular productID in Workflow o

I am using Visual Studio 2008 and .NET 3.5. I am trying to build a WF that is exposed as WCF hosted on IIS. This service is consumed by ASP.NET client. It is a very simple WF- receive info for new product "A"- send email to person 'Xyz' that new prodcut "A" is received- do some business process for product "A"- send out more notifications for product "A"Consider this scenario - - Client hits submit on asp.net page for prodcut "A"- new WF instance is created for product "A"- client can go back to the same page, edit some more info and hit save again. However, this time or for any subsequent "Saves",  I do not want to create a new WF instance for product "A".I can check to see if a WF instance exists for product "A" on the client side before calling the service operation. However, I want to see if there is a way to do this in WF or WorkflowServiceHost, as I don't want to add this logic to client. First acitvity in WF has to be receive activity with CanCreateInstance = true, so not sure how I can do this check in WF itself.Also, I have another stupid question, when using WF exposed as WCF service, do we have to implement all service operations using WF? What if I have some service operations that just involves checking some business logic? Do I implement this in a

LinQ to check if xml node exists in the XML??

Using LinQ or any C# syntax, I just want to know whether "Item" Child exists or not if the parent Node (ChildMenuSelected>>MenuSelected) are true from the below xml format.Xml Format:<MenuDataResult> <Items> <Item> <ItemType>Submenu</ItemType> <ItemTitle>Level22</ItemTitle> <Menu> <MenuSelected>false</MenuSelected> <ChildMenuSelected>false</ChildMenuSelected> </Menu> </Item> <Item> <ItemType>Submenu</ItemType> <ItemTitle>Level21</ItemTitle> <Menu> <MenuSelected>false</MenuSelected> <!--if ChildMenuSelected = true --> <ChildMenuSelected>true</ChildMenuSelected> <Item> <ItemType>Submenu</ItemType> <ItemSubType>0</ItemSubType> <Menu> <!--if MenuSelected = true --> <MenuSelected>true</MenuSelected> <ChildMenuSelected>false</ChildMenuSelected> <!-- whether this below item exists or not --> <Item> <ItemType>Submenu</ItemType> <Menu> <MenuSelected>false</MenuSelected> <ChildMenuSelected

Can not copy: The file exists. (Explorer View)

Hello Community,               I used to copy bunch of files from windows explorer to sharepoint 2007 document library in its explorer view. But now I could not. It gives me error "Can not copy xyz: The file exists". The files does not exists already.             I also created many different new files [Different Name/Different File Type] and copy to server but still no luck. I have logged in to SharePoint with Admin Account and verified that no such file already exists.             I have the many machines and using Windows XP and Windows 7. For Windows 7 I never found the problem and Windows XP [with IE 6] if I use normal user for windows logon [Normal user have the “Full Control” permission in SP] I cannot use drag and drop files. It shows the error message “Cannot copy file <filename> The file exists”. For “My Network Places” I created and point to document libraries such as http://serversite/Docs [“Docs” It’s a document libraries list] but no luck. I tried from multiple Windows XP workstations and It works in few but cannot make out any differences between these machines.          &n

How to check if SPFiled already exists?

hi   I donot know the internal name and cannot use title for retreiving the filed because user can add 2 fields with the same title. Is there anyother option to check if filed already exists?

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

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..

check user exists in which group

After entering user name, i want check user belonging to which group, group is some thing like role based if group is something group1 , then i want redirect hime to page 1, if groupis 2  then page 2 like that

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

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

check if a table exists in SQL 2005

I'm trying to check if a certain table exists in a given database on a SQL 2005 Server. I've tried numerous times without any result.   can anyone point me in the right direction?

Check if custom culture exists

Hello, I created a custom culture using the 'Register' method on the CultureAndRegionInfoBuilder class. But if you execute this method when the culture has already been registered, then an exception will be thrown. So, is it possible to check if the culture is already registered on the machine? Regards, Stefan

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.

sqmapi.dll. Verify that the file exists and that you can access it.

I'm getting the following error when I try to install SQL Server 2008 on Windows Server 2008.  I looked under the following directory to make sure the file wasn't missing.  It is definitely there.  So I'm not sure why I'm getting the error.This is a remote server so I had to mount an ISO to install it.  Any thoughts on this.  I'd like to start using these products.  At this point I can't even install SQL Server 2008.Thanks,JimTITLE: Microsoft SQL Server 2008 Setup------------------------------ The following error has occurred: Error reading from file F:\x86\setup\sql_common_core_msi\PFiles\SqlServr\100\Tools\Binn\VSShell\Common7\IDE\sqmapi.dll.  Verify that the file exists and that you can access it. Click 'Retry' to retry the failed action, or click 'Cancel' to cancel this action and continue setup. For help, click: http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=10.0.1600.22&EvtType=0xF45F6601%25401201%25401 ------------------------------BUTTONS: &RetryCancel------------------------------

check if a url exists

is there a way to check if a url or a website exists?
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