Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

VS 2010 [RESOLVED] run code at specific time

$
0
0
i wrote some code that creates a text file and i would like to run it a specific time once a week. i was wondering what is the best way to do this?

should i create a program and then create a scheduled task in windows xp to run the program at a specific time?


here is the code:

Code:

Dim today As Date = Date.Today
Dim dayDiff As Integer = today.DayOfWeek - DayOfWeek.Sunday
Dim sunday As Date = today.AddDays(-dayDiff)
Dim fileExt As String = sunday.Month.ToString("D2") & "." & sunday.Day.ToString("D2") & "." & sunday.ToString("yy")
Dim csvExt As String = sunday.Year & sunday.Month.ToString("D2") & sunday.Day.ToString("D2")
Dim SaveFilePathName As String = "\\Jobs\Invoice.mjb"

Using sw As New System.IO.StreamWriter(SaveFilePathName, False)
    Dim row As String = Nothing
    row = "[IMPORT-1]"
    row = row & vbCrLf & "LIST=""\\Lists\FILE.dbf"""
    row = row & vbCrLf & "SETTINGS=""Invoice Import"""
    row = row & vbCrLf & "FILENAME=""\\Invoicing\Invoices_" & csvExt & ".csv"""
    row = row & vbCrLf & "PARALLEL=N"
    row = row & vbCrLf & "[SUBLIST-1]"
    row = row & vbCrLf & "LIST=""\\Lists\INVOICES.dbf"""
    row = row & vbCrLf & "FILENAME=""\\Lists\INVOICES " & fileExt & ".dbf"""
    row = row & vbCrLf & "DESCRIPTION=""INVOICES " & fileExt & """"
    row = row & vbCrLf & "OVERWRITE=Y"
    row = row & vbCrLf & "HIDERECORDS=N"
    row = row & vbCrLf & "AUTOOPENLIST=N"
    sw.WriteLine(row)
End Using


Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>