none
Taking input from VB text-box and using it as parameter in C# console application RRS feed

  • Question

  • I have just finished a program that automates working with files. I used a library that makes it very easy to work/edit PDFs in C#.

    What the program does is:

    • Goes into a folder/directory
    • Edits/sanitizes all PDF files in the folder/directory
    • Saves/outputs them into a second folder.

    At the moment, however, my Input and Output folders are Hardcoded. Im simply setting the path using the GetDirectory() method and looping through the files with a Foreach.

    Is there any way I can connect my CS C# file with a Visual Basic form?I simply want to pass whatever is in the form's textbox as a value to the string. The form and the CS. File are in different projects/folders. 

    So instead of string directory = @"hardcoded\folder\path"  --> string directory = textbox1.value.

    Thank you.

    Tuesday, July 31, 2018 12:57 PM

All replies

  • Can you please show for code so we can better understand what you have done as words talking code can be very different than works explaining code with the code supplied in a code block.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, July 31, 2018 2:00 PM
    Moderator
  • That is a literal copy-paste. 

     public static string[] InputFilesDirectory { get; set; } =
                Directory.GetFiles(@"C:\Folders\Christian's Folder\PDFsUnedited","*.pdf");

     public static string[] OutPutFilesDirectory { get; set; } =
                Directory.GetFiles(@"C:\Folders\Christian's Folder\PDFSEdited", "*.pdf");

    I would also post a picture of the situation but it does not let me. 


    • Edited by Grisword Tuesday, July 31, 2018 2:07 PM
    Tuesday, July 31, 2018 2:06 PM
  • At the moment, however, my Input and Output folders are Hardcoded. Im simply setting the path using the GetDirectory() method and looping through the files with a Foreach.

    Is there any way I can connect my CS C# file with a Visual Basic form?I simply want to pass whatever is in the form's textbox as a value to the string. The form and the CS. File are in different projects/folders. 

    So instead of string directory = @"hardcoded\folder\path"  --> string directory = textbox1.value.

    Thank you.

    Hi Grisword,

    According to your description, you want to pass vb.net project value into C# console application. I search from the internet, but I don't find this solution.

    Why do you enter input and output folder in C# console application directly? You can use Console.ReadLine() to get these value.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 2, 2018 6:31 AM