Deleting Files From ArrayList In C#?

Dec 3, 2010

I have an Array List to save selected files and a ListBox to display only the name of the files..my requirement is to delete corresponding files from arraylist when its deleted from listbox...here is my code:

public ArrayList to_compress = new ArrayList();
ListBox pack_lbx=new ListBox();
private void add_btn_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();

[Code]....

View 5 Replies


Similar Messages:

Cleanup Function Deleting Files?

Feb 10, 2011

I created a file cleanup function by using health monitoring. It is deleting file that is no access from another process. So, I want to check this. Is it stay access. If not access, I delete this file. How can I do?

View 1 Replies

Web Forms :: Deleting The Files Automatically?

Jan 30, 2010

In my application i am saving the worddocuments in a folder,I should delete all the prev date files.can i do it automatically? and i am not using any database for the application

View 21 Replies

Web Forms :: Deleting A Folder And Its Subfolders And Files?

Nov 3, 2010

new to asp.net I'm trying to dynamically delete a folder so far I have this code

[Code]....

This works well when there are no files or folders in the directory. But if the directory is not empty then I get an error. How can I delete all the files and folders within that directory

View 1 Replies

VS 2010 Deleting Temp Internet Files?

Mar 3, 2011

I had a page to update user picture and redirect user to login page, the problem is when a user re-login, the old picture is still available until user refresh the page.

notes: I have already use <%@ output> but not working with master page and also have used Response.Cache.SetCacheability(HttpCacheability.NoCache) and also not working

here is my code:

Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnUpdate.Click
'Updating User Pic
fuUserPic.PostedFile.SaveAs(Server.MapPath("~ImagesUserPic" & UserID & ".jpg"))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
FormsAuthentication.SignOut()
FormsAuthentication.RedirectToLoginPage("msg=Please login again")
End Sub

what can I do to delete temp internet files to display picture after updating?

View 9 Replies

.net - Deleting Files When User Logouts Or Session End?

Jun 15, 2010

I'm trying to delete files created by current user when he/she clicks logout button

Protected Sub OnLoggingOut(ByVal sender As Object, ByVal e As EventArgs) Handles LoginStatus1.LoggingOut
Try
Dim folder As String = Server.MapPath("~/uploads/")

[code]...

View 2 Replies

Forms Data Controls :: Deleting Files Within Gridview?

Oct 13, 2010

I have a small website with a database. Just two tables for personaldata and for files belongs to the personal data.

This files are stored on HD. My problem is to delete this file by clicking on delete button within gridview. At the moment only the record is deleting but not the file which belongs to this record.

That is my Gridview:

[Code]....

and that is my codebehind file:


[Code]....

and see the screenshot. (how it looks like)

i get allready help here to create the right codebehind file for that.

i have tried that this way:

[Code]....

But i think instead of txtFile.Text the filename of thefile should be readed out of the database on this place or Im wrong?

View 3 Replies

State Management :: Multidimentional Arraylist / Create A Arraylist Which Will Able To Store User Info?

Jul 16, 2010

i want to create a arraylist which will able to store user info like (username,machineIP,port ) for each user in the list & retrive this data when needed . any one tell me how i can do it or any alternative way without database or xml file.

View 6 Replies

Forms Data Controls :: Gridview And Deleting / Editing Files In Virtual Directory?

Feb 26, 2010

COMPLETE NOOB, dont know anything.. I have a Virtual directory ~/ClubInfoFiles that i upload some files too using a uploader i made. I might want to change the uploader i made to be able to change to a subdirectory or something so i can upload all files into one folder but different subdirectorys. the uploader i would like to be able to have a dropdown menu of all the subdirectorys within "ClubInfoFiles" say i has subfolders : Minutes, Flight Plans, Maintence Records, etc... but i would also like a field to where i can create a new subdirectory and have it automaticly update the dropdown. i want to list those files in gridview and have a link to dowload/open and dellete the files. i have found some code that gets close but it uses Auto Generate columns. really i dont need all that jazz, just the Name, File extention, and hyperlink the file for download/view. i would like to be able to delete and possible upload using the gridview... is this to much for a noob?

[Code]....

[Code]....

[Code]....

View 3 Replies

C# - Getting "process Cannot Access File" Error When Deleting Files After Sending Email?

Feb 7, 2011

I am getting error as mentioned below:

The process cannot access file "E:TempPDFsSample.pdf" because it is being used by another process

I happen to send the pdf from email and after email is sent i need to delete the Sample.pdf file. The code that i have written doesn't work

FileInfo DeleteFileInfo = new FileInfo(directoryPath + "\" + filename + ".pdf");
if (DeleteFileInfo.Exists)
File.Delete(directoryPath + "\" + filename + ".pdf");

here directorypath is E:TempPDFs, filename is Sample

UPDATED:

public static void SendMail(string fromAddress, string[] toAddress, string[] ccAddress, string[] bccAddress, string subject, string messageBody, bool isBodyHtml, ArrayList attachments, string host, string username, string pwd, string port)
{
{
try

[Code]....

View 1 Replies

C# - Deleting From Repeater Item - Erroneous Deleting?

Sep 27, 2010

I have a repeater which binds a set of data. Within this repeater is a column with various controls for updating, deleting, etc. These are image buttons which fire an onclick event such as "DeleteRecord". All this does is fire a stored procedure, passing in the ID of the record to delete from the CommandArgument of the object.

This works wonderfully... except for one rather huge problem. Once you delete a record, if you refresh the page, the record where the first deleted record used to be gets deleted. For instance... if I have 4 records

1 Record1
2 Record2
3 Record3
4 Record4

and I delete record 2... The page reloads with (which is fine):

1 Record1
3 Record3
4 Record4

...if I then hit refresh...

1 Record1
4 Record4

I assume this is because the erroneously deleted object (record3) is now in the same hierarchical place as the old object used to be and .net therefore doesn't know the difference, the page refreshes and fires the onlick event, grabbing out the command argument of the new object and deletes based on the ID as obtained from the commandargument of the new object. This is obviously a huge problem, if a client did this it would destroy data erroneously and I'm at a loss here. Is there any way to stop this from happening? I'm not sure if there is a better way to go about doing things or not. If there isn't, I need some sort of way to tell the page not to execute the event or to cross reference the ID of the object that is intended for deletion against the object itself...

Code below for convenience...

EDIT Wrapped a LinkButton around it because I have some jquery code in here as well which stops the page execution to wait for user confirmation. Pressing "ok" continues page execution.

<asp:LinkButton ID="oDeleteLink" CssClass="oDeleteIcon" CommandName="Delete" CommandArgument='<%# Eval("iAccountID") %>' runat="server">
<asp:ImageButton ImageUrl="/files/system/icons/trash-steel-16.png" ToolTip="Delete This Account" AlternateText="Delete" ID="oDeleteIcon" runat="server" />
</asp:LinkButton>
protected void oAccounts_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {
if (e.CommandName == "Delete") {
int ID = e.CommandArgument.ToString().Numeric();
db.SPs.SpDeleteAccount(ID).Execute();
UI.Confirm(uiBroadcast, "Account has been deleted", "300px");
BindAccounts();
}
}

View 2 Replies

2 Dimensional ArrayList In VB.NET?

Jun 16, 2010

I am looping through a dataset and I would like to have the following in this array list

name, from, to, price
john, 40, 50, 39.99
mike, 20, 50, 49.99
etc.

Once I do that, or if it is possible to do it using the dataset that will work with me. But I want to do...

If john's price between from and to...

So in my code I wanted to make it easy for me and instead of memorizing the row #, I would just do.. arraylist.row("john").item("from")

View 6 Replies

C# - How To Convert A Arraylist To String

Dec 6, 2010

How can I convert a arraylist to a string?

View 4 Replies

ADO.NET :: How To Order An Arraylist With Linq

Sep 9, 2010

Is there a way I can sort this query result in Linq? I'd like to sort in descending order by the .Count parameter:

[Code]....

View 2 Replies

ArrayList Binding To Gridview?

Jan 26, 2011

I have an arraylist of string items that I want to bind to a gridview.I want to bind the value from each item to a asp:HyperLinkField but I dont know what the DataTextField should be? The arraylist obviously doesn't have a column heading as it's just 1 dimensional.What value do I need to use in the DataTextField?

View 3 Replies

Web Forms :: Distinct Arraylist Value Using C#?

Feb 22, 2010

how to distinct arraylist value using c#?

View 10 Replies

Accessing ArrayList In Javascript

May 10, 2010

I have ArrayList in my Model and want to iterate through it in my javascript. I am using following code but its giving me error : CS0103: The name 'i' does not exist in the current context

for(var i=0; i <= <%=Model.KeyList.Count%>; i++)
{
alert('<%=Model.KeyList[i]%>');
}

How to get rid of this?

View 3 Replies

How To Do Empty Arraylist In Immediate Window

Jun 8, 2010

how can i do empty Arraylist in immediate window in asp.net

View 1 Replies

IComparer For ArrayList.sort?

Feb 28, 2010

How to compare array in arraylist by name.I try many thing but no one works.public class myReverserClass : IComparer { int IComparer.Compare( Object x, Object y ) { ... }

View 1 Replies

Storing ArrayList Of Different Objects?

Feb 26, 2010

Is there an easy way of storing an ArrayList containing different custom objects? I guess the easiest way for me would be to use a foreach to store each object into our database, but how would I read them out of the db and assigning them to the correct class?

View 8 Replies

Delete All Arraylist Item?

Jan 11, 2010

how can i delete all arraylist item?

View 6 Replies

.net - Storing 3 Arraylist Into One List In C#?

Mar 17, 2011

I have three ArrayLists with string elements and I want to store them into one List/ArrayList/String Array/Dictionary.

I mean I want to add them. I don't know which one How can I do it? What should I use?

It is in asp.net/c#.

View 3 Replies

C# - Filling An Arraylist From A Datareader?

Mar 15, 2011

I have a problem with how to fill an array list from a data reader

string queryDTL = " SELECT * FROM tbl1 ";
connection.Connect();
cmd = new OracleCommand(queryDTL, connection.getConnection());
dr_DTL = qcmd2.ExecuteReader();
ArrayList RecordsInfo = new ArrayList();
while (dr_DTL.Read())
{
RecordsInfo = dr_DTL["number"].ToString();
}

The problem is the datareader contain alot of info other than the number but I don't know how to put them in their correct position.

View 3 Replies

Passing ArrayList To Another Page?

Jan 2, 2011

I have a gridview with a column of checkboxes. On checking the checkboxes, they have to click on a drop down list that will redirect them to another page. The value of the checkboxes are stored in an arraylist. However, the problem is how can i pass the arraylist to the redirected page?

View 2 Replies

Can Store Image Data In Arraylist

May 15, 2010

Can i store Image data in Array list.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved