Click here to Skip to main content
15,437,947 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
This is NOT a how do I code it question.
I am sure we all have ways of saving various code snippets.
I decided to develop a application that stores links to a folder on my C drive.
In my case I use Sublime Text to create the copied code file.
One issue I have noticed is that NOT adding an extension to the file name will result in
the user needing to select the program to open the file.
If I add .txt then the default program in my case is Sublime Text.
So first question is add the extension to the file or not?

The fields I have considered adding to the DB are as follows.
Code Description Code Type Link URL and Used in Project
At this time I see no point in adding a DATE field as that info is already on the file.
Second questions is there other information you would consider valuable to include?

The process to view this data would be to place the fields in a DataGridView
where the user could select the row to open the file for viewing.
Code Type would not be displayed in the DGV. (See Below)
From the Start Form the user could select to Edit, Delete or View the data.

The Code Type field would be in a Combo Box that would have types added and if the type
did not have a corresponding SubFolder one would be created under the main folder.
Third question is this over complication that adds no great functionality?

This brings me back to using Code Type in the DB so when viewing the user could
have the option to only view various code types by selecting the code type from the ComboBox.
Your thoughts on this are more than welcomed and appreciated.
Last question is there a better way to get the code from VS 2019 into Sublime Text?

I have considered using OpenFileDialog like this and going directly into the source repos. I am not sure I want to do that if I break it not sure I can fix it!
Here is my tentative code


Private Sub btnCopyFile_Click(sender As Object, e As EventArgs) Handles btnCopyFile.Click
    'Create Directory
    'Dim fullPath = "C:\A A Code Vault\VB.Net\"
    'Directory.CreateDirectory(fullPath)
    '===========================================
    'Be sure to place a OpenFileDialog Control on the Form
    'I suggest naming it OpenFileDialog NOT OpenFileDialog1
    'You will need to add Imports System.IO
    '========================================================
    Dim openFileDialog As OpenFileDialog = New OpenFileDialog()
    Dim dr As DialogResult = openFileDialog.ShowDialog()

    If dr = System.Windows.Forms.DialogResult.OK Then
        Dim pathSource As String = openFileDialog.FileName
        Dim fileName As String = System.IO.Path.GetFileName(openFileDialog.FileName)
        MsgBox("Path " & pathSource & " " & fileName)
        Dim sSource As String = pathSource
        Dim sTarget As String = "C:\A A Code Vault\VB.Net\" & fileName

        Dim folder As String = "C:\A A Code Vault\VB.Net\"
        If Not System.IO.Directory.Exists(folder) Then
            System.IO.Directory.CreateDirectory(folder)
        End If

        File.Copy(sSource, sTarget, True)

    End If
End Sub


What I have tried:

I have tested the code but not on the source repo folder. Chicken
Posted
Updated 8-Feb-22 2:53am
Comments
PIEBALDconsult 8-Feb-22 9:28am     CRLF
I would likely store the snippets in the database. I would not use a DataGridView.
Choroid 8-Feb-22 12:11pm     CRLF
Thanks Yes the DB will only store the links to the files on the C drive Just using the DGV to view the Link Path
PIEBALDconsult 8-Feb-22 12:17pm    
Right, but I don't think that's a good idea.

1 solution

Quote:
So first question is add the extension to the file or not?
Every file should have an appropriate extension indicating the file type. Not all text files have to end in txt. How a file is opened depends on your Default Apps system settings
Quote:
Second questions is there other information you would consider valuable to include?
That very much depends on what you need/want to store. However, I will say that you do NOT want to store Used in Project with the other data. You should have a "many-to-many link table" that links Projects to Code Files as any one code file may be used in multiple projects (encourages re-use) and each project will contain multiple code files.
Quote:
Third question is this over complication that adds no great functionality?
The implication is that you have a separate folder for each code type - so this doesn't seem to me to be an over-complication
Quote:
Last question is there a better way to get the code from VS 2019 into Sublime Text?
The question doesn't seem to go with the preceding statements. The files are not really going from VS 2019 into your text editor - they are files within VS 2019 project folders that you are opening in an alternative text editor.
Quote:
From the Start Form the user could select to Edit, Delete or View the data.
Edit might be fine - but why would you do that in an external editor instead of Visual Studio? Deleting a file through your new tool is not a good idea - you will also need to update the other project files - at which point you start getting into the realms of trying to rewrite Visual Studio. Pointless exercise.
Quote:
I have tested the code but not on the source repo folder. Chicken
You do have a backup don't you?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900