[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Tranfere Files From Windows to Unix directories.

Posted on 2004-11-23
4
Medium Priority
?
166 Views
Last Modified: 2010-04-24
Hi,

I'm not sure what the best way of doing this is but I have access to Visual Studio.net, and throught of making a simple application (.exe) so that other people can select a file from a windows network and move it or copy it to a Unix root directory, I know there are programs that they can download for free, but I just want to make a simple application for them.

Just need some suggestions on where to go with this.

Thanks.
0
Comment
Question by:mmatharu
2 Comments
 
LVL 18

Accepted Solution

by:
armoghan earned 500 total points
ID: 12653339
Hi mmatharu,
few ways
1. Either use FTP to transfer . You have to use the FTP api
2. Make a Samba share. that will act as Network Share in NT systems. so the transfer will be no more difficult then copying it to a Share
3. install a webBrowser and Make an uploading mechanism via Web (Not a good way)

Cheers!
0
 
LVL 2

Assisted Solution

by:JohnnyGr
JohnnyGr earned 500 total points
ID: 12667897
If you need it secure you can build a wrapper around the pscp.exe program wich is a SSH transfer program, requires SSH server on the unix box tho...

Code:

Imports System.IO
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(5, 5)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(224, 20)
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = ""
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(235, 5)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(64, 22)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Browse"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(5, 35)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(295, 20)
        Me.Button2.TabIndex = 2
        Me.Button2.Text = "Send file to server"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(302, 61)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Select file
        Dim fileBrowser As New OpenFileDialog
        With fileBrowser
            .ShowDialog(Me)
            If DialogResult.OK Then
                TextBox1.Text = .FileName
            End If
        End With
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If File.Exists(TextBox1.Text) Then
            'Wrap the plink binary

            Dim strPscpPath As String = Application.StartupPath & "\pscp.exe"
            Dim strUsername As String = "unix_username"
            Dim strPassword As String = "unix_password"
            Dim strSourceFilename As String = TextBox1.Text
            Dim strDestinationHost As String = "unix_host"
            Dim strDestinationPath As String = "/target/dir/"

            Dim pscp As New System.Diagnostics.ProcessStartInfo
            pscp.FileName = strPscpPath
            pscp.Arguments = "-pw " & strPassword & " " & Chr(34) & strSourceFilename & Chr(34) & " " & strUsername & "@" & strDestinationHost & ":" & strDestinationPath

             Dim pscpProcess As Process = System.Diagnostics.Process.Start(pscp)

        End If
    End Sub
End Class



This requeres the pscp.exe file in the same dir as your application... pscp also takes multiple input files and so on...

just an idea...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question