Dear Friends i made a applicatoin where i need a variable value which will enter by after 1st installation...

Infact it is a uploading to ftp application with a single click. but the file name is not constant for all all locatins. So i want i will enter it in first run and it should be saved.

i think you understand what i want ...

You can use a custom setting. In the Settings tab of the project properties, set the name and the data type. You don't have to put a value if you don't need it. If the setting is called "Filename", your code would look like this:

 My.Settings.Filename = "MyFile.txt"

Thanks Tinstaafl ... here is the code File which i am uploading ... after uploading its going to rename ..... MSSAT001.DAT

Now you can give me a better solution

Public Class FrmUpload
    Public Function newext() As String
        Dim pickdate As DateTime = DateTime.Now
        Dim strdate As String
        strdate = pickdate.ToString("m")
        Dim strsplit() As String
        strsplit = strdate.Split(" ")
        If strsplit(0) = "January" Then
            strsplit(0) = "A"
        ElseIf strsplit(0) = "February" Then
            strsplit(0) = "B"
        ElseIf strsplit(0) = "March" Then
            strsplit(0) = "C"
        ElseIf strsplit(0) = "April" Then
            strsplit(0) = "D"
        ElseIf strsplit(0) = "May" Then
            strsplit(0) = "E"
        ElseIf strsplit(0) = "June" Then
            strsplit(0) = "F"
        ElseIf strsplit(0) = "July" Then
            strsplit(0) = "G"
        ElseIf strsplit(0) = "August" Then
            strsplit(0) = "H"
        ElseIf strsplit(0) = "September" Then
            strsplit(0) = "I"
        ElseIf strsplit(0) = "October" Then
            strsplit(0) = "J"
        ElseIf strsplit(0) = "November" Then
            strsplit(0) = "K"
        ElseIf strsplit(0) = "December" Then
            strsplit(0) = "L"
        Else
            strsplit(0) = ""
        End If

        newext = strsplit(0) + strsplit(1)

    End Function






    Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
        Application.Exit()
    End Sub

    Private Sub BtnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUpload.Click

        Dim dtm As DateTime = Date.Now
        If dtm.Hour < 22 Then
            MsgBox("Its Too Early try After 10.00 Clock", MsgBoxStyle.Information)
            Exit Sub
        ElseIf DateAndTime.Now.DayOfWeek = DayOfWeek.Thursday Then
            MsgBox("Dont need to Upload its Week End", MsgBoxStyle.Information)
            Exit Sub

        Else

            Try

                lblprog.Visible = True
                Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.FtpWebRequest.Create("ftp://ftp.uibonline.com/uibsat/mssat900.dat"), System.Net.FtpWebRequest)
                request.Credentials = New System.Net.NetworkCredential("ksauib@uibonline.com", "123456")
                request.Method = System.Net.WebRequestMethods.Ftp.UploadFile

                Dim file() As Byte = IO.File.ReadAllBytes("C:\syn\bajrai\msdata\mssat900.dat")


                Dim strs As IO.Stream = request.GetRequestStream()
                strs.Write(file, 0, file.Length)


                strs.Close()
                strs.Dispose()
                MsgBox("File Uploaded", MsgBoxStyle.Information)
                lblprog.Visible = False

                My.Computer.FileSystem.RenameFile("c:\syn\bajrai\msdata\mssat900.dat", "mssat900." & newext() & "")


            Catch ex As Exception

            End Try




        End If

    End Sub

there is no permanent variable,
you need persistent storage like file, database

What are you looking for that's better than using the settings?

When you rename the file, that's the filename you want to save. Just follow the instructions I gave you and substitute in the new filename. `My.Settings.Filename = "mssat900." & newext()

You might need to add My.Settings.Save(), just to make sure the setting gets saved.

You might find this better for your newext function:

Public Shared Function newext() As String
    newext = Chr(Now.Month + 64) + Now.Day.ToString
End Function

That should be the same output you're looking for. For instance today would return "E10"

Dear Tintaafl I want that i can cahnge MSSAT900.dat ... when i install the application

i mean ....
dim filename as string
DirectCast(System.Net.FtpWebRequest.Create("ftp://ftp.uibonline.com/uibsat/'&FileNname&' "), System.Net.FtpWebRequest)

then

Dim file() As Byte = IO.File.ReadAllBytes("C:\syn\bajrai\msdata\'& FileName &' ")

and in the end

My.Computer.FileSystem.RenameFile("c:\syn\bajrai\msdata\mssat900.dat", " "& FileName. &"" & newext() & "")

I just pass file name 1st time its starts after installation... some give me seggestion for Serialaization ... but i dont have idea about it also :(

Dear 1a2p3a4c5h6e ... can you give me any example for using file ... not data base ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.