I'm trying to load the most recent file from a directory, but my following code doesn't work. Am i getting something obvious terribly wrong?!
Dim myFile = Directory.GetFiles("C:UsersJoeDesktopXML Logs").OrderByDescending(Function(f) f.LastWriteTime).First()
I get two error messages:
Data type(s) of the type parameter(s) in extension method 'Public Function OrderByDescending(Of TKey)(keySelector As System.Func(Of String, TKey)) As System.Linq.IOrderedEnumerable(Of String)' defined in 'System.Linq.Enumerable' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
I have a number of files in a folder, I need to get the last modified date. So I used FDate = IO.File.GetLastWriteTime(FName) Works fine with some files, but on others, I get a date of 1/1/1601. But when I check the files in Windows Explorer, all the dates look normal (recent). So, I'm gessing there are multiple files dates stored in the file system, and the ones dotnet is seeing are not the ones windows is seeing. How can I get exactly the date which appears as "date modified" in a file explorer window? I tried some vb6 api stuff but that doesn't seem to work in dotnet.
I have two parts of code; one is searching (InStr) if log file contains certain string and the other one find the last modified log in one folder.Now I would like to merge these two together and modify so the script finds the last modified log file from all the logs in folder that contain certain string.hese are the two code snipets:1. finds a string in log file:
Const ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set folder = objFSO.GetFolder("C:\folder\")
I'm currently viewing files in a specific directory and then displaying them in the first column of a Listview. I want to be able to display the last modified date and time in the second column. I've tried Google, but I haven't had much luck. I'll post the code that I'm using at the moment, below.
I am trying to pull the modified date of one file in a folder through a SSIS script. I tried doing this through the system.IO namespace as it contains the GetFileName method. This isn't working & I was wondering if there was a name space that contained the modified date method for a file if I specified the path to the filename. I am looking to return the modified date variable in whichever way this may be possible.
I'm using VB.net 2003 Standard Edition, and I'm trying to retrieve the file modified date. I've created a System.IO.FileInfo object, and have collected info from the three methods: CreationTime, LastAccessTime, and LastWriteTime, but they aren't giving me the same data as XP Windows Explorer is.In Explorer, there is a Date Modified field (currently reading 2008 on the file in question), but using the FileInfo methods they return 2007, 2009, 2009.Is there another IO object I can use to get this 'modified' date?
I created a background thread that constantly scans a specified folder for any .xls files that are created or modified. These files come from a vba macro in outlook that will automatically save the attachments of the mails in the this folder. This will update the modified date/time, or at least it seems to.
For Each fi In aryFi fidate = System.IO.File.GetLastWriteTime(path & fi.ToString) fidate1 = System.IO.File.GetCreationTime(path & fi.ToString)
Everytime I check to the code, the fidate and fidate1 variables are indeed the correct dates/times of the file it's currently checking. It almost never gets inside the elseif block at runtime though.
I have an ftp routine which gets various files from a server and puts them on a client PC.My problem is it loses the original Last Modified Date on the client PC. I can get the last datetime modified from the server but don't know how to assign this to the file on the client PC. Is there away to alter the last modified datetime?
I have created installer from Visual Studio Package and Deployment, but after successful installation, the installer files (like dlls, images and all supporting files) modified date or even creation date has been changed and all have the same date depends on the date of installation. Is there a way I can preserve or maintain it's original creation/modified date?
I have a page which lists all the files in a particular folder (all PDFs), using a data-table and gridview. I'm currently sorting this table by the filename (by using a dataview), which isn't that helpful, and I want the gridview of files sorted by the file created or file modified date (as recorded in Windows). If that's not possible, a second option would be to extract the date from the file name string (no problem doing that), and sort the dataview/datatable or gridview based on that.
I have read about Network.Downloadfile and I think I understand it! I want to know if there is an easy way to test a files date modified before downloading it. I have a lot of files in the folder. I really want to "sync" the folder. I don't want to copy every file every time I want to only download the file if I don't have the file in the destination location or if I have an Old copy.
So there's this accounting package at my client that spits out text-based reports with invalid dates, like February 31st or September 31st.The reports are formatted with spaces and mono-spaced fonts. The data that gets parsed out are fed into a more formal local SSRS report, and that's about all you need to know.
What I am interested in fixing is the situation where a date is invalid and can't be converted into a DateTime struct. The date format from the report is "MMM-dd-yy" (e.g. "Feb-30-10"). The date strings need to be fixed before being shown in the formal report. I've seen this done two ways in my time as a developer, and I want to come up with a cleverer way of doing it (if there isn't a built-in way I don't know about).The first bad method (I can't believe I'm even showing you!):
Dim month As Integer = <Parse out the month from the bad date string> Dim day As Integer = <Parse out the day from the bad date string> Dim year As Integer = <Parse out the year from the bad date string> Dim validDate As DateTime
I have a modified button control with a string array in it. I am having trouble sending the string array to the form with the modified button on it. Anyone know what i can do? The form uses a arrayList to hold the buttons since they are made at runtime.
I am using following code to search my computer for files with certian extensions. I currenty searching for .eml files. This code lists all files found.I need to enter 10 most current files' path to my list box.[code]...
I m using vb.net with access 2007. I have field with datatype "datetime" and values in format dd/mm/yyyy e.g 8/2/2011. Now I have problem when i fire a query SELECT * FROM tbl_name WHERE tbl_name.datefield= (Select Max(tbl_name.datefield) from tbl_name)); I have some records with dates 11/1/2011 and some records with dates 8/2/2011 but I get wrong result records with date 11/1/2001 instead I want records with date 8/2/2011
I ran into a problem on a program that is ALMOST done!
I have a populated listview of say 100 image directories. of those 100 images, there are groups of 20-30 images. this number isn't always the same, but would be between 20-30 per group. the time stamp would be within 5 minutes on each grouping. how would I go about pulling the most recent only of the 100 or so images? the most recent within about 5 minutes on the time stamp.
I am good in excel and access coding but preety new in VB.net, I wish to prepare an application which will pull details of all the recent users logged in under a particualr domain along with the computer name. I this possible?I did a lot of google and got ActiveDs.IADsContainer and ActiveDs.IADsUser.
I have two datetimepicker controls now when I select February 22, 2010 from datetimepicker1 which is Monday I want the other datetimepicker2 to be February 25, 2010 which is Thursday. This means that I want datepicker2 to automatically look for the Thursday value of the week. I have set my week start day as Saturday and ends on Thursday, Friday is holiday.
I'm creating a report in MS SQL Server Reporting Services and need to set the default Start and End Date report parameters to be the first and last dates of previous calendar month and need help.The report is generated on the 2nd calendar day of the month and I need values for:
Previous Calendar Month - first day - last day
I've been working with DateAdd, but have not been successful at creating an Expression (in VB.NET as I understand it).
I have a 500K+ lines vb.net app, written by 10+ different devs over the past 5 years. Many times it gets the system time and/or date and relies on it.Now I have to re-run real cases thru the program for regression testing purposes, and it screws up cases where the date/time matter. My fix is easy, just replace all the areas in the program that get current date/time with a sub that gets the current date/time, UNLESS I'm testing, in which case it will return the date/time of the original run. I have tried searching the sourcecode for the obvious 'current date/time' functions:
Now DateAndTime.TimeOfDay Date.ToDay
However, if I miss one, I LOSE.list more ways to get the current time, that might be hidden in the source code, that I can search for? Note: It's pretty clear none of the 3rd party libs in this system are returning date, well, one is, but I've caught it.
I need to find the date of Monday this week programmatically.For example, for this week Monday was on the 9th, so the date I need is: 09/11/2009.And when we roll over to next week it needs to calculate: 16/11/2009..I have tried doing this myself but I can't see how to do the arithmetic.
I need to find the system date change made by the user, i can find out this by checking the event log, and the event log can be deleted so it is not good idea.Can anyone suggest a method to find out the system date change in windows?
how I could retrieve the date/time of the last Group Policy update. I have a crude routine that will search the Event Log for Event 1704, but this runs slower than I'd like. I was hoping there might be a way to get this info via Registry, WMI query, etc. that would work faster in my VB2010 program.