Results 1 to 25 of 25

Thread: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox2

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox2

    Dear all master,

    please help I want to change the hard code to the selected path from the browsing dialog folder (I marked yellow in the code below)

    and the problem listbox2 is not showing the patch directory. I attached a picture of the problem listbox2.

    thanks
    roy88
    Code:
    Public Class Form1
        Private FullFilePathName As String = ""
        Dim w As Watermarker = New Watermarker("demo", "demo")
        Dim twm As TextWatermark = New TextWatermark
    Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
            Using dlg As FolderBrowserDialog = New FolderBrowserDialog()
    
                Dim dr As DialogResult = dlg.ShowDialog(Me)
                If dr = DialogResult.OK Then
                    ListBox2.Items.Clear()
                    For Each file As String In dlg.SelectedPath
                        If String.IsNullOrEmpty(FullFilePathName) Then FullFilePathName = System.IO.Path.GetDirectoryName(file)
                        twm.Text = "Copyright � John Doe, 2008"
                        twm.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
                        twm.TextColor = Color.Red
                        twm.Transparency = 40
                        twm.Alignment = TextAlignment.Center
                        twm.Placement = WatermarkPlacement.BottomRight
                        twm.Margins = New WatermarkMargins(20, 20, 20, 20)
                        w.AddWatermark(twm)
                        w.OutputOptions.OutputDirectory = "c:\emp\output"
                        w.Execute()
                        ListBox2.Items.Add(file)
                    Next
                End If
            End Using
        End Sub
    End Class
    Attached Images Attached Images  

  2. #2
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Hello,

    for the yellow line , you can try

    Code:
    w.OutputOptions.OutputDirectory =dlg.SelectedPath.tostring
    and please don't use anymore yellow color, it is just unreadable with a white background

    EDIT : sorry, I misread the code so I removed the first part of my comment
    Last edited by Delaney; Aug 24th, 2021 at 09:49 AM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  3. #3
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Why do you use a listbox? a label or a textbox should be enough as with FolderBrowserDialog you cannot select several folders
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by Delaney View Post
    Hello,

    I don't understand really what you want, it seem that textbox2 is the first box and it gives the file list with the path because that's what you code with that
    Code:
    ListBox2.Items.Add(file)
    . and it has nothing to do with the yellow line.

    please clarify.
    dear sir
    my answer 1 : what I mean is listbox2 is the position below and I attach the screenshot file below
    so it doesn't match the result unlike listbox1 at the top.
    else for the yellow line , you can try

    Code:
    w.OutputOptions.OutputDirectory =dlg.SelectedPath.tostring
    and please don't use anymore yellow color, it is just unreadable with a white background
    my answer 2 :according to your additional code it works perfectly and I'm sorry because I marked yellow

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    this is the screenshot file I mean
    Attached Images Attached Images  

  6. #6
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    by the way this is of no use, and you choice of variable name is terrible

    Code:
    For Each file As String In dlg.SelectedPath
    selected path is a path not a file and there is only one path
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  7. #7
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by roy88 View Post
    this is the screenshot file I mean
    Yep I figured, the use of the word "file" for a path misguided me. See my previous comments. And use a texbox or a label instead of the listbox.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by Delaney View Post
    Why do you use a listbox? a label or a textbox should be enough as with FolderBrowserDialog you cannot select several folders
    So I want to display a list of directory files that are input in listbox1 and files are output in listbox2 so that in the future I can choose from the listbox to appear in the picturebox

  9. #9
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    if you keep your listbox2, just remove the for each and use
    Code:
    ListBox2.Items.Add(dlg.SelectedPath)
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by Delaney View Post
    if you keep your listbox2, just remove the for each and use
    Code:
    ListBox2.Items.Add(dlg.SelectedPath)
    dear sir,
    Ok. I removed the code "for each" but the results in the listbox do not get the image file name, only the directory. You can see the image file below.
    Attached Images Attached Images  

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    You seem to think that the paths of the files in the selected folder will materialise by magic. They won't. If you want the file paths in a folder then you have to get them. One option for doing that is to call Directory.GetFiles.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    in you code you use "FolderBrowserDialog" so you will get only a path and nothing else. What exactly do you want to get ? a list of files without the path ?
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by jmcilhinney View Post
    You seem to think that the paths of the files in the selected folder will materialise by magic. They won't. If you want the file paths in a folder then you have to get them. One option for doing that is to call Directory.GetFiles.
    dear sir
    how's the code?
    thanks

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by Delaney View Post
    in you code you use "FolderBrowserDialog" so you will get only a path and nothing else. What exactly do you want to get ? a list of files without the path ?
    I want the path with the list of files

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by Delaney View Post
    in you code you use "FolderBrowserDialog" so you will get only a path and nothing else. What exactly do you want to get ? a list of files without the path ?
    I use FolderBrowserDialog to select the output folder and I want the path with the list of files

  16. #16
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    this will get you all the files (just the name) from a path

    Code:
    Dim di As New IO.DirectoryInfo(dlg.SelectedPath)
    Dim arrayfiles As IO.FileInfo() = di.GetFiles("*.*")
    Dim fi As IO.FileInfo
    
    ListBox2.Items.Add(dlg.SelectedPath) ' first i add the path
    For Each fi In arrayfiles  ' second I add the files
        'you can try to put you code here
    
        ListBox2.Items.Add(fi.Name) 
    Next
    PS : .SelectedPath is a string so no need to add .tostring (see post#2), sorry for that
    Last edited by Delaney; Aug 24th, 2021 at 10:34 AM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by Delaney View Post
    this will get you all the files (just the name) from a path

    Code:
    Dim di As New IO.DirectoryInfo(dlg.SelectedPath)
    Dim arrayfiles As IO.FileInfo() = di.GetFiles("*.*")
    Dim fi As IO.FileInfo
    
    ListBox2.Items.Add(dlg.SelectedPath) ' first i add the path
    For Each fi In arrayfiles  ' second I add the files
        'you can try to put you code here
    
        ListBox2.Items.Add(fi.Name) 
    Next
    PS : .SelectedPath is a string so no need to add .tostring (see post#2), sorry for that
    dear sir,

    sorry i'm late reply. I tried with your code it didn't work. The results in the list are also not there and the output image file is also not there.

    thanks
    Code:
     Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
            Using dlg As FolderBrowserDialog = New FolderBrowserDialog()
    
                Dim dr As DialogResult = dlg.ShowDialog(Me)
                If dr = DialogResult.OK Then
                    Dim di As New IO.DirectoryInfo(dlg.SelectedPath)
                    Dim arrayfiles As IO.FileInfo() = di.GetFiles("*.*")
                    Dim fi As IO.FileInfo
                    ListBox2.Items.Add(dlg.SelectedPath) ' first i add the path
                    For Each fi In arrayfiles  ' second I add the files
                        twm.Text = "Copyright � John Doe, 2008"
                        twm.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
                        twm.TextColor = Color.Red
                        twm.Transparency = 40
                        twm.Alignment = TextAlignment.Center
                        twm.Placement = WatermarkPlacement.BottomRight
                        twm.Margins = New WatermarkMargins(20, 20, 20, 20)
                        w.AddWatermark(twm)
                        w.OutputOptions.OutputDirectory = dlg.SelectedPath.ToString
                        w.Execute()
                     ListBox2.Items.Add(fi.Name)
                    Next
                End If
            End Using
        End Sub
    Attached Images Attached Images  

  18. #18
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    846

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    As I don't know what this part does or should do :

    Code:
     twm.Text = "Copyright � John Doe, 2008"
    twm.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
    twm.TextColor = Color.Red
    twm.Transparency = 40
    twm.Alignment = TextAlignment.Center
    twm.Placement = WatermarkPlacement.BottomRight
    twm.Margins = New WatermarkMargins(20, 20, 20, 20)
    w.AddWatermark(twm)
    w.OutputOptions.OutputDirectory = dlg.SelectedPath.ToString
    w.Execute()
    I cannot help you more. Sorry.
    The code I gave to you in post#16 works (gives the path and the files in the path), I tested it. So they may be some problem with your watermark code. I cannot test your code as I don't have watermark library or functions
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by Delaney View Post
    As I don't know what this part does or should do :

    Code:
     twm.Text = "Copyright � John Doe, 2008"
    twm.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
    twm.TextColor = Color.Red
    twm.Transparency = 40
    twm.Alignment = TextAlignment.Center
    twm.Placement = WatermarkPlacement.BottomRight
    twm.Margins = New WatermarkMargins(20, 20, 20, 20)
    w.AddWatermark(twm)
    w.OutputOptions.OutputDirectory = dlg.SelectedPath.ToString
    w.Execute()
    I cannot help you more. Sorry.
    The code I gave to you in post#16 works (gives the path and the files in the path), I tested it. So they may be some problem with your watermark code. I cannot test your code as I don't have watermark library or functions
    dear sir,
    if I use the code below the output of the watermark works, only the listbox2 problem results. I attach a picture of the listbox2 problem. I can attach the demo library problem if you want.
    thanks
    Code:
    Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
            Using dlg As FolderBrowserDialog = New FolderBrowserDialog()
    
                Dim dr As DialogResult = dlg.ShowDialog(Me)
                If dr = DialogResult.OK Then
    For Each file As String In dlg.SelectedPath
    twm.Text = "Copyright � John Doe, 2008"
                        twm.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
                        twm.TextColor = Color.Red
                        twm.Transparency = 40
                        twm.Alignment = TextAlignment.Center
                        twm.Placement = WatermarkPlacement.BottomRight
                        twm.Margins = New WatermarkMargins(20, 20, 20, 20)
                        w.AddWatermark(twm)
                        w.OutputOptions.OutputDirectory = dlg.SelectedPath.ToString
                        w.Execute()
                        ListBox2.Items.Add(dlg.SelectedPath)
                        'ListBox2.Items.Add(fi.Name)
                    Next
                End If
            End Using
        End Sub
    Attached Images Attached Images  

  20. #20
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    You're just not listening to what you're being told. The SelectedPath of the FolderBrowserDialog is the path of the selected folder. What possible use could it be to add that folder path to the ListBox over and over? If you want to display the file paths then add the file paths. If you want to add the file names then add the file names. DO NOT add the folder path. That's about the third time you've been told that. Maybe you'll actually do it this time.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  21. #21
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    If I wanted to display the file paths in the ListBox, I would do this:
    vb.net Code:
    1. Dim folderPath = dlg.SelectedPath
    2. Dim filePaths = Directory.GetFiles()
    3.  
    4. ListBox2.DataSource = filePaths
    That's it. You can then loop over the file paths and process each file:
    vb.net Code:
    1. For Each filePath In filePaths
    2.     'Use filePath here.
    3. Next
    If you want to display the file name rather than the full path:
    vb.net Code:
    1. Dim folder = New DirectoryInfo(dlg.SelectedPath)
    2. Dim files = folder.GetFiles()
    3.  
    4. With ListBox2
    5.     .DisplayMember = "Name"
    6.     .ValueMember = "FullName"
    7.     .DataSource = filePaths
    8. End With
    and then:
    vb.net Code:
    1. For Each file In files
    2.     Dim filePath = file.FullName
    3.  
    4.     'Use filePath here.
    5. Next
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by jmcilhinney View Post
    If I wanted to display the file paths in the ListBox, I would do this:
    vb.net Code:
    1. Dim folderPath = dlg.SelectedPath
    2. Dim filePaths = Directory.GetFiles()
    3.  
    4. ListBox2.DataSource = filePaths
    That's it. You can then loop over the file paths and process each file:
    vb.net Code:
    1. For Each filePath In filePaths
    2.     'Use filePath here.
    3. Next
    If you want to display the file name rather than the full path:
    vb.net Code:
    1. Dim folder = New DirectoryInfo(dlg.SelectedPath)
    2. Dim files = folder.GetFiles()
    3.  
    4. With ListBox2
    5.     .DisplayMember = "Name"
    6.     .ValueMember = "FullName"
    7.     .DataSource = filePaths
    8. End With
    and then:
    vb.net Code:
    1. For Each file In files
    2.     Dim filePath = file.FullName
    3.  
    4.     'Use filePath here.
    5. Next
    dear sir
    there is an error for the first solution
    Code:
     Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
            Using dlg As FolderBrowserDialog = New FolderBrowserDialog()
    
                Dim dr As DialogResult = dlg.ShowDialog(Me)
                If dr = DialogResult.OK Then
                    Dim folderPath = dlg.SelectedPath
                    Dim filePaths = Directory.GetFiles()
    ListBox2.DataSource = filePaths
    For Each filePath In filePaths
     twm.Text = "Copyright � John Doe, 2008"
                        twm.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
                        twm.TextColor = Color.Red
                        twm.Transparency = 40
                        twm.Alignment = TextAlignment.Center
                        twm.Placement = WatermarkPlacement.BottomRight
                        twm.Margins = New WatermarkMargins(20, 20, 20, 20)
                        w.AddWatermark(twm)
                        w.OutputOptions.OutputDirectory = folderPath.ToString
                        w.Execute()
                        'ListBox2.Items.Add()
                        'ListBox2.Items.Add()
     Next
                End If
            End Using
        End Sub

  23. #23

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by roy88 View Post
    dear sir
    there is an error for the first solution
    Code:
     Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
            Using dlg As FolderBrowserDialog = New FolderBrowserDialog()
    
                Dim dr As DialogResult = dlg.ShowDialog(Me)
                If dr = DialogResult.OK Then
                    Dim folderPath = dlg.SelectedPath
                    Dim filePaths = Directory.GetFiles()
    ListBox2.DataSource = filePaths
    For Each filePath In filePaths
     twm.Text = "Copyright � John Doe, 2008"
                        twm.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
                        twm.TextColor = Color.Red
                        twm.Transparency = 40
                        twm.Alignment = TextAlignment.Center
                        twm.Placement = WatermarkPlacement.BottomRight
                        twm.Margins = New WatermarkMargins(20, 20, 20, 20)
                        w.AddWatermark(twm)
                        w.OutputOptions.OutputDirectory = folderPath.ToString
                        w.Execute()
                        'ListBox2.Items.Add()
                        'ListBox2.Items.Add()
     Next
                End If
            End Using
        End Sub
    error :Error Overload resolution failed because no accessible 'GetFiles' accepts this number of arguments.
    Code:
    Dim filePaths = Directory.GetFiles()

  24. #24
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Sorry, that should be:
    vb.net Code:
    1. Dim filePaths = Directory.GetFiles(folderPath)
    Of course, you could have figured that out for yourself with a bit of effort. Did you read the documentation for the Directory.GetFiles method? You should have, and it would have told what was expected. You're allowed to think for yourself and you should do so before asking for others' help. That's the way to learn.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  25. #25

    Thread Starter
    Lively Member
    Join Date
    Aug 2021
    Posts
    91

    Re: Change Hard Code To Selected Pach From Folder Browsing Dialog and problem listbox

    Quote Originally Posted by jmcilhinney View Post
    Sorry, that should be:
    vb.net Code:
    1. Dim filePaths = Directory.GetFiles(folderPath)
    Of course, you could have figured that out for yourself with a bit of effort. Did you read the documentation for the Directory.GetFiles method? You should have, and it would have told what was expected. You're allowed to think for yourself and you should do so before asking for others' help. That's the way to learn.
    dear sir,
    I tried your code it didn't work. I made my own code and it worked to appear in listbox2 but the watermarking process didn't work. The solution should be looping as a string. the code below I marked the color that was the problem.

    thanks
    Code:
    Public Class Form1
     
        Dim w As Watermarker = New Watermarker("demo", "demo")
        Dim twm As TextWatermark = New TextWatermark
    Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click
            Dim result As DialogResult = FolderBrowserDialog1.ShowDialog
            If (result = DialogResult.OK) Then
                'Show the path using the text box
                TextBox1.Text = FolderBrowserDialog1.SelectedPath
                'Obtain information about the path
                Dim selectedPath As DirectoryInfo = New DirectoryInfo(TextBox1.Text)
                'Clear the list box first 
                ListBox2.Items.Clear()
              
                'Show all the directories using the ListBox control
                For Each file As FileInfo In selectedPath.GetFiles
    
                    twm.Text = "Copyright � John Doe, 2008"
                    twm.Font = New WatermarkFont("Arial", FontStyle.Bold, FontSizeType.Percents, 2)
                    twm.TextColor = Color.Red
                    twm.Transparency = 40
                    twm.Alignment = TextAlignment.Center
                    twm.Placement = WatermarkPlacement.BottomRight
                    twm.Margins = New WatermarkMargins(20, 20, 20, 20)
                    w.AddWatermark(twm)
                    w.OutputOptions.OutputDirectory = TextBox1.Text
                    w.Execute()
                    ListBox2.Items.Add(file.Name)
                Next
            End If
        End Sub
    End Class

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width