Files
Lecteur-media/lecteur/lecteur média/exportplaylist.vb
T
2026-06-18 14:15:48 +02:00

183 lines
9.0 KiB
VB.net
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Imports System.ComponentModel
Imports System.IO
Imports System.Net
Public Class exportplaylist
Dim dl As Integer = 0
Dim tc As String = ""
Dim drive As Integer = 0
Private Sub exportplaylist_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim lines1a() As String = File.ReadAllLines(théme)
If lines1a(0) = 2 Then
Me.BackColor = Color.FromArgb(64, 64, 64)
ComboBox1.BackColor = Color.FromArgb(64, 64, 64)
Label1.BackColor = Color.FromArgb(64, 64, 64)
Label1.ForeColor = Color.White
ComboBox1.ForeColor = Color.White
ProgressBar1.BackColor = Color.FromArgb(64, 64, 64)
ElseIf lines1a(0) = 3 Then
Me.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
ComboBox1.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
Label1.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
Label1.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB)
ComboBox1.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB)
ProgressBar1.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
Else
End If
ProgressBar1.Hide()
ProgressBar1.Style = ProgressBarStyle.Marquee
ProgressBar1.Value = 0
ComboBox1.Items.Clear()
Label1.Show()
ComboBox1.Show()
Me.Text = "Exporter une playlist"
For Each fichier As String In IO.Directory.GetDirectories(dosplaylist)
Dim info As New IO.DirectoryInfo(fichier)
ComboBox1.Items.Add(info.Name)
Next
End Sub
Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedValueChanged
Dim lines7() As String = File.ReadAllLines(comtpeco2)
If lines7(0) = 1 Then
Try
Dim maj As New WebClient
Dim vri As String = maj.DownloadString("http://lecteur2.lecteur-media.fr/lecteur/server%20temps.txt")
If vri = 1 Then
If FolderBrowserDialog1.ShowDialog = 1 Then
tc = ComboBox1.SelectedItem
If File.Exists(FolderBrowserDialog1.SelectedPath & "\ " & My.Computer.Name & " - exportation playlist - " & tc & ".zip") = True Then
MsgBox("Le fichier: " & My.Computer.Name & " - exportation playlist - " & tc & ".zip" & " existe déjà", MsgBoxStyle.Exclamation)
Close()
Else
Label1.Hide()
ComboBox1.Hide()
ProgressBar1.Show()
Me.Text = "Exportation en cours"
dl = 1
BackgroundWorker1.RunWorkerAsync()
End If
Else
MsgBox("Merci de sélectionner un dossier de destination", MsgBoxStyle.Critical)
End If
Else
Dim msg = MsgBox("Voulez-vous l'exporter sur votre drive ?", MsgBoxStyle.YesNo)
If msg = MsgBoxResult.Yes Then
tc = ComboBox1.SelectedItem
FolderBrowserDialog1.SelectedPath = repertoire
Label1.Hide()
ComboBox1.Hide()
ProgressBar1.Show()
Me.Text = "Exportation en cours"
dl = 1
drive = 1
BackgroundWorker1.RunWorkerAsync()
Else
If FolderBrowserDialog1.ShowDialog = 1 Then
tc = ComboBox1.SelectedItem
If File.Exists(FolderBrowserDialog1.SelectedPath & "\ " & My.Computer.Name & " - exportation playlist - " & tc & ".zip") = True Then
MsgBox("Le fichier: " & My.Computer.Name & " - exportation playlist - " & tc & ".zip" & " existe déjà", MsgBoxStyle.Exclamation)
Close()
Else
Label1.Hide()
ComboBox1.Hide()
ProgressBar1.Show()
Me.Text = "Exportation en cours"
dl = 1
BackgroundWorker1.RunWorkerAsync()
End If
Else
MsgBox("Merci de sélectionner un dossier de destination", MsgBoxStyle.Critical)
End If
End If
End If
Catch ex As Exception
If FolderBrowserDialog1.ShowDialog = 1 Then
tc = ComboBox1.SelectedItem
If File.Exists(FolderBrowserDialog1.SelectedPath & "\ " & My.Computer.Name & " - exportation playlist - " & tc & ".zip") = True Then
MsgBox("Le fichier: " & My.Computer.Name & " - exportation playlist - " & tc & ".zip" & " existe déjà", MsgBoxStyle.Exclamation)
Close()
Else
Label1.Hide()
ComboBox1.Hide()
ProgressBar1.Show()
Me.Text = "Exportation en cours"
dl = 1
BackgroundWorker1.RunWorkerAsync()
End If
Else
MsgBox("Merci de sélectionner un dossier de destination", MsgBoxStyle.Critical)
End If
End Try
Else
If FolderBrowserDialog1.ShowDialog = 1 Then
tc = ComboBox1.SelectedItem
If File.Exists(FolderBrowserDialog1.SelectedPath & "\ " & My.Computer.Name & " - exportation playlist - " & tc & ".zip") = True Then
MsgBox("Le fichier: " & My.Computer.Name & " - exportation playlist - " & tc & ".zip" & " existe déjà", MsgBoxStyle.Exclamation)
Close()
Else
Label1.Hide()
ComboBox1.Hide()
ProgressBar1.Show()
Me.Text = "Exportation en cours"
dl = 1
BackgroundWorker1.RunWorkerAsync()
End If
Else
MsgBox("Merci de sélectionner un dossier de destination", MsgBoxStyle.Critical)
End If
End If
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim sw1 As New StreamWriter(CStr(dosplaylist & tc & "\nom.txt"))
sw1.WriteLine(tc)
sw1.Close()
IO.Compression.ZipFile.CreateFromDirectory(dosplaylist & tc & "\", FolderBrowserDialog1.SelectedPath & "\ " & My.Computer.Name & " - exportation playlist - " & tc & ".zip")
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
If drive = 0 Then
ProgressBar1.Style = ProgressBarStyle.Blocks
ProgressBar1.Value = 100
dl = 0
File.Delete(dosplaylist & ComboBox1.SelectedItem & "\nom.txt")
MsgBox("Lexportation de la playlist: " & ComboBox1.SelectedItem & " est terminer", MsgBoxStyle.Information)
Close()
Else
File.Delete(dosplaylist & ComboBox1.SelectedItem & "\nom.txt")
updrivre()
End If
End Sub
Private Sub exportplaylist_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
If dl = 1 Then
e.Cancel = True
MsgBox("Lexportation de la playlist: " & ComboBox1.SelectedItem & " est en cours" & vbNewLine & "merci de patientez", MsgBoxStyle.Critical)
Else
End If
End Sub
Sub updrivre()
ProgressBar1.Style = ProgressBarStyle.Blocks
ProgressBar1.Value = 0
ProgressBar1.Hide()
Dim lines1() As String = File.ReadAllLines(compteco)
Text = "Envoie sur votre drive"
Dim fifier As String = ipserver & "utilisateur/" & lines1(0).ToString & "/Dirve/" & My.Computer.Name & " - exportation playlist - " & tc & ".zip"
Dim fifiersource As String = FolderBrowserDialog1.SelectedPath & "\ " & My.Computer.Name & " - exportation playlist - " & tc & ".zip"
My.Computer.Network.UploadFile(fifiersource, fifier)
dl = 0
drive = 0
File.Delete(fifiersource)
FolderBrowserDialog1.SelectedPath = ""
MsgBox("Lexportation de la playlist: " & ComboBox1.SelectedItem & " est terminer", MsgBoxStyle.Information)
Close()
End Sub
End Class