.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

Delete file in a subfolder using Updatelistitems web method

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :C#


I need to delete zip file under my folder and sub folders which are under the list name named "Documents", so i used



GetListItems web method and got the list zip files. When i try to delete the same i am not able to delete the ones that are in the folders (i.e) if the zip file is under [http://server/mysite/Documents/Folder/aaa.zip].

I am adding the line of code which am using for deleting the file from the list.

 XmlDocument xmlDoc = new System.Xml.XmlDocument (); 

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?

Calling parameterized method from aspx file


Hi all,
I have following method
 public string GetYoutubeVideo (string code)
        return "asasdasfa"

why I can not upload file to web by using WebClient.UploadFile method?



I am using WebClient.UploadFile method to upload a file to a web page.

The code is like this:

WebClient client = new WebClient(); 
byte[] responseBinary = client.UploadFile(url, fileName); 
string response = Encoding.UTF8.GetString(responseBinary);

But I can not upload it to server.

I used fiddler to see what happens, and it shows me the following information:

http status code: 302, request headers: POST /testing/upload/default.aspx HTTP/1.1

http status code: 302, request headers: GET /testing/upload/default.aspx?AspxAutoDetectCookieSupport=1 HTTP/1.1

http status code: 200, request headers: GET /(X(1)S(22pynhvxd3eqsb455pudx145))/testing/upload/default.aspx?AspxAutoDetectCookieSupport=1 HTTP/1.1

I would like to know, why I get 302 code, and why it redirect me to the strange url with (X(1)S(22pynhvxd3eqsb455pudx145)) ?

By the way, the web page is ok to upload file by using web explorer.


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.

Overload POST with X-HTTP-Method-Override as DELETE

Hi, How do I pass POST with the override header, X-HTTP-Method-Override, which will say I really mean DELETE in REST WCF 3.5? What changes are needed exactly in server side REST code & where to make those changes exactly? Can some one post code snippet? Thanks!

How to set and map a Method in the Service file with endpoint elements and binding elements

Hi all, I have created a service file like OSService.svc in that i have two methods like one is FileUpload and FileDownload for e.g :- [WebInvoke(UriTemplate = "/fileupload/{fileName}" , Method = "POST" )]         [OperationContract]         void FileUpload(string fileName, Stream fileContents); same as Filedownload also. People you may know these methods are inside the interface of service file what you are using i'e i have created a interface as IOSService.cs. So, what i need now is i want to write separate endpoint for FileUpload and Filedownload.Because i want to set separate value for receiveTimeout  and openTimeout for the Fileupload and FileDownload process in binding section in the web.config file itself. The below code was i'm using right now but still i'm not able to the set separate value of endpoint elements in the bindings. EndPoint Section:- <endpoint name = "endPoint1"  address  = "localhost:8000/OSService.svc/" bindingConfiguration = "TransactionalTCP"   binding  = "netTcpBinding"          contract = "IOSService"/> Binding Section:-  <binding name = "TransactionalTCP"  transactionFlow = "true"   /&

Cannot delete rows in a list via Lists web service's UpdateListItems-function, even though I am abl

Hi all, I'm trying to delete some rows in a SharePoint 2010 Foundation list via Lists.asmx -web service's UpdateListItems. The web service is called from BizTalk. I am able to create rows, but for some reason delete fails. I also use "GetListItems"-function without problems. The exception I get is Microsoft.SharePoint.SoapServer.SoapServerException. The message is "Cannot access a closed Stream." The updates-element of the UpdateListItems-function is as follows (well, a part of it, the real one has more Method-elements, but you get the gist..): <Batch OnError="Continue" ListVersion="1"> <Method ID="1" Cmd="Delete"> <Field name="ID">1900</Field> <Field name="IMEI">GFA-687</Field> </Method> <Method ID="2" Cmd="Delete"> <Field name="ID">1901</Field> <Field name="IMEI">OVG-567</Field> </Method> <Method ID="3" Cmd="Delete"> <Field name="ID">1902</Field> <Field name="IMEI">OXI-570</Field> </Method> </Batch> I've also tried that Batch without the IMEI-information, as well as with a valid ViewName. Why cannot I delete when I can clearly modify/create rows - what's up with th

How to delete an image file assigned to a PictureBox xontrol ?

In a Windows form application, some image files are assigned to PictureBox controls. I am trying to delete those image files. The first approach [1] with "Image.FromFile" gives an error message of "Another process is using this image file", although "Image.Dispose()" is executed. The second approach [2] using "Image.FromStream" results (X) images for PictureBoxes and Buttons, if "fs.Close()" is inclided. Without "fs.Close()", it gives the same error message of "Another process is using...". How can I display images properly and delete those images files ? Thanks [1] pictureBoxSelected.Image = Image.FromFile(@actualImage); . . . pictureBoxSelected.Image.Dispose(); pictureBoxSelected.Image = Image.FromFile(@tempImage);                                                if (System.IO.File.Exists(actualImage) == true) {     System.IO.File.Delete(actualImage); } [2] FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); pictureBox.Image = System.Drawing.Image.FromStream(fs); fs.Close();

How to delete a file which was accessed by other process ?

Does Windows have a "unlock object" method in order to delete a file which is being used by another process ? Thanks

Log file WSS_AdminService.log - can i delete it?

Hi, I've noticed that the size of a file WSS_AdminService.log every user profile setting eg. in C:\Documents and Settings\Default User\Local Settings\Temp is about 2GB currently. I understand that this file is updated by wssadmin.exe (the Windows SharePoint Services Administration service). questions: 1. we have many users who are no longer using the account to login to the server, can i delete teh file then? 2. is there a way that i can allow only a single file WSS_AdminService.log in a specific user account to be access by wssadmin.exe? in this case we can save more HDD space. because, if we have more than 50 users account, then 50 * 2GB and it's already 100GB. instead of 100GB, can we just make it 2GB and this file is share by all the sharepoint users? thanks. Sam. Does anyone have any insight into how I might alter what is logged or how often, or even just to persuade it to 'housekeep' better, as the file continues to grow (reaching 750MB on the first server I noticed this on)? As far as I can see it is not related to the Diagnostic logging settings in Central Administration > Operations. Renaming the file to append a date on a regular basis is my current solution - a new copy is then created by WSS Admin on its next log cycle.

delete a csv file created via StreamWriter?

I don't know if this is the correct forum.. but, is there a way I can automatically delete the following .csv file that was created via streamwriter (after it is viewed by an individual)?CODE (I would like to automatically delete the_filename.csv)://///////////////////////////////////////////////////////////////////////////////////////////////            string filename = "~/downloadfiles/data_complex987654321_filename.csv";             StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));             StringBuilder sb = new StringBuilder();            string filename = "~/the_filename.csv";            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));            StringBuilder sb = new StringBuilder();

File.AppendAllText method writes garbage?

When I execute the below code multiple times on a file, it writes garbage values in file...    string msg = "Ajmera";  File.AppendAllText("F:\\deep.txt", msg);     File content after 15-20 writes :-  ???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? Why does it happens?

can not delete data file after emptying the file

hi, i have two data file groups. data and data_new. i moved all objects from file group data to data_new. i verified not a single object is there in data file group. i want to remove all files in file group data and and evantually filegroup as well. i am trying to delete the file present in this file group. but it is throwing error cant be deleted because file is not empty .any one plz suggest.

delete file from server

hello champs...i want to delete the folders present in server...but when writing  System.IO.File.Delete(Server.MapPath("~/uploads/loading.zip"))or directory.delete(path,true)it is giving error of permission denied...again if i manually change the permission of that folder for user type: users to modify,read,write full control then end user can delete the folder. how to solve it...pro grammatically

Session Expires on File Delete

Dear All, I am trying to delete Files and Directory through ASP.NET3.5 (C#)web application. But as soon as Directory\File is deleted It  automatically redirects me to Login Page. It means I am lossing my session on deleting File/Directory. Plz help me out.

How can i delete the file uploaded in my web page?

 Hi Experts. I am writing a simple web page that  users can upload an image file. After the file is uploaded, Users can fill up  other question in the web page. then users click the submit button to register them and the file is uploaded previously is move to special folder and is saved there. Know i want to delete the uploaded file if the user upload the file but dont click the submit button and close the web page. because i dont need the file uploaded until the user is not registered. I use Session_End event but i dont know why it dont work. With Regards. Mojtaba

Can't delete database-file

HelloThis has been driving me crazy all day and I've had to shutdown the website so I'm pretty stressed right now.I'm trying to delete ASPNETDB.MDF on a server but I keep getting the error "Cannot delete ASPNETDB: It is being used by another person or program". I've shut down both the website and the SQL Server service but the problem remains.I've also tried detaching it using 'sp_detach_db' but get:"CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened".The server is running Windows Server 2003 and Microsoft SQL Server 2005 Express.Any suggestions?Thanks.
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