I am programing to have a file deleted in X- amount of days: for (int i = 0; i &lt; 5; i++)         {             System.IO.DirectoryInfo fi = new DirectoryInfo(m_strfilename[i].Text);             if (fi.LastAccessTime &lt; DateTime.Now.AddDays(-Convert.ToInt32(m_dropdown[i].Value)))                 fi.Delete();  I am not quite sure what the issue is with this.
27910
I'm using .NET 3.5, trying to recursively delete a directory using:  Directory.Delete(myPath, true);   My understanding is that this should throw if files are in use or there is a permissions problem, but otherwise it should delete the directory and all of its contents.  However, I occasionally get this:  System.IO.IOException: The directory is not empty.     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)     at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)     at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)     ...   I'm not surprised that the method sometimes throws, but I'm surprised to get this particular message when recursive is true.  (I know the directory is not empty.)  Is there a reason I'd see this instead of AccessViolationException?
102464
I suffer from a problem of      value does not fall within the expected range   from below code.           string webUrl = "/_layouts/15/wfcourrierdep/ArticlesList.aspx";                 string fullpath = SPUtility.GetFullUrl(SPContext.Current.Site,                    webUrl);          SPFile file = web.GetFile(fullpath);   What can the cause be?
56248
I have a script that deletes files 7 days or older and then logs them to a folder. It logs and deletes everything correctly but when I open up the log file for viewing, its very sloppy.  log=$HOME/Deleted/$(date)  find $HOME/OldLogFiles/ -type f -mtime +7 -delete -print &gt; "$log"   The log file is difficult to read  Example File Output: (when opened in notepad)  /home/u0146121/OldLogFiles/file1.txt/home/u0146121/OldLogFiles/file2.txt/home/u0146121/OldLogFiles/file3.txt   Is there anyway to log the file nicer and cleaner? Maybe with the Filename, date deleted, and how old it was?  Any suggestions help!
104197
When i create new User Account and login with that credentials, it gives me this problem if admin doesnt have set thier values yet !!!**  AllotmentList = [select id, Days_Remaining__c from PTO_Allotment__c where Year__c =:year and Employee__c=:EmployeeList[0].id LIMIT 100]; //access only Current user Allotment details                 //to handle Listoutof Bound Exception wrote if-else          if(AllotmentList.size()&gt;0)         {         requests.PTO_Allotment__c=AllotmentList[0].id;         requests.Days_Remaining__c=AllotmentList[0].Days_Remaining__c;         }         else         {             //write a code when AllotmentList is empty ....         }
93841
When I try to delete one of these two shortcuts, a message appears saying, "If you remove this file, Windows or another program may no longer work correctly."! I don't think that it is possible to keep same named files into a single directory. Is this any malware or anything harmful for my PC?
84742
For the following block of code:  For I = 0 To listOfStrings.Count - 1     If myString.Contains(lstOfStrings.Item(I)) Then         Return True     End If Next Return False   The output is:  Case 1:  myString: C:\Files\myfile.doc listOfString: C:\Files\, C:\Files2\ Result: True   Case 2:  myString: C:\Files3\myfile.doc listOfString: C:\Files\, C:\Files2\ Result: False   The list (listOfStrings) may contain several items (minimum 20) and it has to be checked against a thousands of strings (like myString).  Is there a better (more efficient) way to write this code?
78638
How can I iterate over each file in a directory using a for loop?  And how could I tell if a certain entry is a directory or if it's just a file?
7708
How to add days to current Date using JavaScript. Does JavaScript have a built in function like .Net's AddDay?
71247
List&lt;String&gt; nameList = new List&lt;String&gt;(); DropDownList ddl = new DropDownList();   List is populated here, then sorted:  nameList.Sort();   Now I need to drop it into the dropdownlist, which is where I'm having issues (using foreach):  foreach (string name in nameList){     ddl.Items.Add(new ListItem(nameList[name].ToString())); }   No workie - any suggestions? It's giving me compile errors:  Error - The best overloaded method match for 'System.Collections.Generic.List&lt;string&gt;.this[int]' has some invalid arguments   Error - Argument '1': cannot convert from 'string' to 'int'
26226
I need a robust and simple way to remove illegal path and file characters from a simple string. I've used the below code but it doesn't seem to do anything, what am I missing?  using System; using System.IO;  namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {             string illegal = "\"M&lt;&gt;\"\\a/ry/ h**ad:&gt;&gt; a\\/:*?\"&lt;&gt;| li*tt|le|| la\"mb.?";              illegal = illegal.Trim(Path.GetInvalidFileNameChars());             illegal = illegal.Trim(Path.GetInvalidPathChars());              Console.WriteLine(illegal);             Console.ReadLine();         }     } }
70164
Lets say I have this array,  int[] numbers = {1, 3, 4, 9, 2};   How can I delete an element by "name"? , lets say number 4?  Even ArrayList didn't help to delete?  string strNumbers = " 1, 3, 4, 9, 2"; ArrayList numbers = new ArrayList(strNumbers.Split(new char[] { ',' })); numbers.RemoveAt(numbers.IndexOf(4)); foreach (var n in numbers) {     Response.Write(n); }
19895
I'm writing a bash script that needs to delete old files.  It's currently implemented using :  find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete   This will delete of the files older than 1 day.  However, what if I need a finer resolution that 1 day, say like 6 hours old? Is there a nice clean way to do it, like there is using find and -mtime?
87437
I'm trying to beat my head against the syntax of this. I'm getting problems with whitespaces and I can't see if there's a better way to do this.  vardir=/home/user cd $vardir for i in $(ls "$vardir") ; do timestamp="$(stat -c %Y $i)" echo "$i" echo "$timestamp"  done   Result is similar no matter where I quote and I'm not sure what I'm doing wrong:  stat: cannot stat ‘Temporary’: No such file or directory Temporary  stat: cannot stat ‘Items’: No such file or directory Items   My goal is I want to grab the timestamps off of backup directories and touch the current ones to restore the original modified dates.
113129
Is there any clever method out there to make my executeEveryDayMethod() execute once a day, without having to involve the Windows TaskScheduler?
120362
Eclipse created a temp folder in one of the directories which is nested quite deep, e.g.  dir1\dir1\dir1\dir1\...   I am unable to delete this folder in Windows via Explorer, the del or rmdir commands, nor the Cygwin 'rm' command.  How should I remove this very long folder?  It just keeps saying "File name too long..."
116559
I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly.  That is, if I have a date of 'Today', I want to get the date for 'Yesterday'.  It always seems to take more code than necessary when I do this, so I'm wondering if there's any simpler way.    What's the simplest way of doing this?  [Edit: Just to avoid confusion in an answer below, this is a JavaScript question, not a Java one.]
46094
I am trying to display a list of all files found in the selected directory (and optionally any subdirectories). The problem I am having is that when the GetFiles() method comes across a folder that it cannot access, it throws an exception and the process stops.  How do I ignore this exception (and ignore the protected folder/file) and continue adding accessible files to the list?  try {     if (cbSubFolders.Checked == false)     {         string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath);         foreach (string fileName in files)             ProcessFile(fileName);     }     else     {         string[] files = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.*", SearchOption.AllDirectories);         foreach (string fileName in files)             ProcessFile(fileName);     }     lblNumberOfFilesDisplay.Enabled = true; } catch (UnauthorizedAccessException) { } finally {}