.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

SP to fetch the specific file name in a specified folder

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :Sql Server


How to fetch a file name of specific  file type from a specified folder. To simplify

Assume 'Test.xxx'  is the file name in 'D:\test' folder. Need a sp which takes the drive as input parameter and fetch the output 'Test'.

Thanks in advance.

View Complete Post

More Related Resource Links

Programmatically delete a .webpart file from wpcatalogs folder from an IIS website


We are using a third party wsp in our solution which directly adds the web parts into the web application store rather than the web part gallery(References to them are present in IIS site's wpcatalog directory). We want to remove these web part files so that the users will not be able to add these web parts to pages directly. Or any other modification so that users will not be able to add these directly. Is there a way we can do this programmatically?

Method/Way to know whether a input path of FilesSystem contains any Child file/folder or not

Hi,I am looking for a Method/Way to know whether a input path of FilesSystem contains any Child file/folder or not. To know it currently I am using "Directory.GetFileSystemEntries(Path).Count" and checking if count > 0 then returning True else False. For this first method calculates all the files and folder and then return status to me but I want to exit out as soon as my method gets first element(file/folder) in specified path. Because above method is timing out when my input path contains more than 1 million files. I just need to check whether input folder path contains any child file/folder or not. I have tried to use Win32 API also but on ther server it is crashing so I donot want to use that solution. In .NET any method or way is present to know it. Please suggest me.

Web Folder problem : This file cannot be saved to this location because there is no connection to th

When I check out a Word 2007 document from a list, I cannot save it back to the server.  I get:   This file cannot be saved to this location because there is no connection to the server.  Check your network connection and try again.   I am using a Virtual Machine (Virtual PC).  I have the Microsoft Loopback adapter installed.    The server has a static IP address and is a domain controller. I am able to access the web folder through Windows Explorer.   How do I set up Office, Sharepoint and Webdav so that I can check files out of sharepoint and save them back, on a virtual machine?

using application configuration file in AppData special folder

Hi! So I understand it is a best practice to save the application configuration files under the AppData folder, rather than in Program Files, since UAC will restrict write acces to the Program Files folder, which is fine. Now, saving the configuration file to another location is no problem, using the SaveAs method. However, when I load the application, I expect some settings to be read. From what I know, this is done either using direct calls to the ConfigurationManager class, either initializing a Configuration object. For the first case, a example is this: if (ConfigurationManager.AppSettings["Title"] != null) { this.Title = ConfigurationManager.AppSettings["Title"]; titleTextBox.Text = ConfigurationManager.AppSettings["Title"]; } For the second case, I would use it like this: Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); string setting = config.AppSettings.Settings["Title"].Value.ToString(); So, if the application runs in the Program Files folder, an exception is thrown when I save the file. However, if I save the file using SaveAs and save it to AppData folder, obviously, when loading, the settings are not loaded from the AppData folder, but from the configuration file existing in the Program Files folder. One way to solve

Saving Image File in a Folder on Sever from Client Machine using Sql Server

  Hi EveryOne... Can anyone help me Saving an Image file in a Server folder from a client machine using Sql server 2005....   

specified file or folder name is too long

Hi, We have MOSS 2007 SP1 databases on SQL Server 2005 SP3. All are 64 bit. We are intermittingly seeing the below  message in ULS log.: 09/01/2010 07:07:16.34 w3wp.exe (0x14BC)                       0x0D14 Windows SharePoint Services   General                                       8kh7      High       The specified file or folder name is too long. The URL path for all files and folders must be 260 characters or less (and no more than 128 characters for any single file or folder name in the URL). Please type a shorter file or folder name   But I'm unable to find the root cause that is causing this issue. I want to find which particular document or process or url is  cauisng this error? Where can I get that info? Whenever we see the above message in ULS logs, we are also experiencing blocking in SQL Server and users are facing very slow performance. Please advice Thanks

SSIS FOR each loop to load 1 file after other into database for particaular folder

HI I am using ssis 2008,i have folder in which i have 10 excel file.i wont to load them one after other in data  base I have created a Dataflow task that load one file into database.i have inserted this dataflow task into For each loop and in For each loop i have give that folder path and *.XLSX  and in variable mapping i have created one variable  which i have passed in Database destination connecion string (properties->expression) but still i get error "cannot acquire connection from connection manager" please guide me or provide me with some reference so that i cud load file from folder into database one after other

Deleting the file from sharepoint folder gives error

Hi All, I am trying to delete a file from sharepoint it show error like this: <Result ID=\"1,Delete\" xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\"><ErrorCode>0x80070005</ErrorCode><ErrorText>The operation failed because an unexpected error occurred. (Result Code: 0x80070005)</ErrorText>

how to get ListItems in Specific folder and not in subfolder ?

Hi,  following query gives me the items in subfolder also, but i need items in specific folder only.   not in subfolder.   what needs to be modified?     string folderQuery = " <Contains><FieldRef Name=\"FileRef\" /><Value Type=\"Text\">" + folderName + "</Value></Contains>";                SPQuery query = new SPQuery();                               query.Query = "<Where><And>"+folderQuery+" <Eq><FieldRef Name='FSObjType'/><Value Type='Lookup'>0</Value></Eq><And></Where>";                                                                           query.RowLimit = 500;             &nbs

Getting file count on folder basis

Hi, I am getting the count of items modified in last 30 days. But I would like to get it a folder and sub folder basis. How to achieve this. [CODE]  int coa = 0; foreach (SPListItem item in AuditList.Items) {    DateTime CurDate = DateTime.Now;    DateTime gesDate = item.File.TimeLastModified;    TimeSpan t1 = CurDate - gesDate  ;    if (t1.TotalDays <= 30)   {         coa++;    } } Console.WriteLine("count is" + coa); [/CODE] How to achieve the above . Thank you

Dealing with a changing folder value in Foreach File Enumerator

I have a Foreach Loop component that loops through files in a folder.  That folder doesn't exist on the server where I'm going to move the package to.  Within the Foreach Loop Editor, the Enumerator Configuration Folder doesn't appear to be able to take a variable value.  Also, it doesn't appear that there's a "Folder" property in the expressions property list. Is there some way I can use a variable value for this foreach file loop's folder location?  I need to move the package to the dev server and then eventually to the prod server.  I don't mind manually opening the *.dtsx file on each server to change the values accordingly, but I would think there's a better way. Any advice you could offer would be greatly appreciated.  The dev and prod servers have SQL Server 2008 R2 with SSIS 2008 R2 on Windows 2008 Server. Thanks, everybody.

DataView upload save file goes nowhere. How do you set a folder to upload to? Dynamically?

I have a Dataview bound to Document Library with the New Document button enabled. It apears to upload but can't find the files anywhere. I don't have a Shared Document folder. How and where do you set where to upload the file? A specific folder would be nice and If I could make it dynamic tied to QueryString Ideal. Going a bit further, the library I'm bound to has many 3 digit numeric folders that are dynamically created when entries are added to another list. The page that is calling my dataview has a querystring that will tie into the folder I want to drop files into. Just wondering how I can dynamically set the upload destination. Currently this is the generated code: <input type="button" value="Save" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit')}" /> <a href="javascript: {ddwrt:GenFireServerEvent('__cancel;dvt_1_form_insertmode={1}')}">Upload File</a> I have some other code that calls the classic file upload page that is working perfectly, but I'd really prefer the clean and simple UI of the DataView control if I could make it work. Thanks!

Scheduled Folder and File cleanup


Does moss have a built in way to schedule file and folder deletion besides "disposition approval"? (i.e. every 90 days) If not built in, what options are out there? Thanks.

Folder's file count getting mismatched



I have a folder, which contains sub folders. For example: Doc is the root folder. Inside it has 2 sub folders named Doc1 and Doc2.

Doc1 contains 2 sub folders - fol1 and fol2.

"fol2" folder does not contain any files, where as "foc1" has a file in it. I am trying to get the count of files modified in last 30 days. Against each of the sub folders,and the corresponding parent folder i want to show the count of modified items. I am getting the sub folders count, but that count is not getting updated to the parent folder.

I am missing a small part of updation, but not sure where it is. This is the code i have used:


public static void GetOpenItems()
SPFolder folder = list.RootFolder;
int mouas = 0;

if (folder != null && folder.Name.CompareTo("Forms") != 0)
//Get Individual Folder Total
 foreach (SPFolder subFolder in folder.SubFolders)
  if (subFolder.Name.CompareTo("Forms") != 0)
  mouas = CountFilesInFolder(subFolder, System.DateTime.Now.AddDays(-30));
  subFolder.Item["Files_Count"] = mouas;

static int CountFilesInFolder(SPFolder folder, DateTime startDate)

Fetch specific information(string) from another website and display the same in my website


I am beginner and need help.

I want design a page where the end user enters information on my page and related information is fetched from the another website on my web page.

For example: Capturing City and state name from USPS.com

End user Task : Enter zipcode and click button 'Fetch' 

My page perform few task

1. opens usps site backend

2. Enters the zipcode

3. Captures city name and state as temporary value from the usps

4. Displays the same in labels present in my home page.

I need help and designing the same.

Execute a SSRS Report from CRM using URL to output to PDF with a specific file name


We have a CRM installation from which I am trying to do some reports which use the CRMAF filters so the reports are sensitive to entitiy selections.

eg execute a sales report for a number of selected accounts.

The specific RDLs have been created in VS2008 and uploaded to the reporting server via the Report import tools within CRM and all work as expected however the output of the report is in HTML via the web browser.

I have changed the configuration of the report in CRM so that it uses the URL method like below so that the report is rendered into PDF which is great.



This method prompts for the user to open/save the PDF file which is acceptable however I would like to replace the default file name (which is the report name) with one of my own.

For example rather

Master Page with CCS file in a Folder


I have a CCS file that I used with my MasterPage, however I wanted to move it with my other Style Sheets to a folder called StyleSheets.  But when I update the:

<link href="~/StyleSheets/SS_TDBG.css" rel="stylesheet" type="text/css" />

I lose my background image?

Here is my StyleSheet:




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