2021-10-19T16:17:35+02:00
2021-10-19T16:17:46+02:00
2022-08-12T05:05:29+02:00
helloc
Sziasztok!
Nagyon egyszerű dolgot szeretnék. Ha rákattintok a button3-ra, akkor legyen figyelve a path_import könyvtár. Ha a mappába bele kerül egy *.mp4 fájl, akkor a label1 szövege legyen: új fájl.
Form1.cs
Mi a probléma?
Nagyon egyszerű dolgot szeretnék. Ha rákattintok a button3-ra, akkor legyen figyelve a path_import könyvtár. Ha a mappába bele kerül egy *.mp4 fájl, akkor a label1 szövege legyen: új fájl.
Form1.cs
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FirstApp
{
public partial class Form1 : Form
{
public static string path_import = "";
private void button3_Click(object sender, EventArgs e)
{
FileSystemWatcher watcher = new FileSystemWatcher(@path_import);
watcher.NotifyFilter = NotifyFilters.Attributes
| NotifyFilters.CreationTime
| NotifyFilters.DirectoryName
| NotifyFilters.FileName
| NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.Security
| NotifyFilters.Size;
watcher.Changed += OnChanged;
watcher.Filter = "*.mp4";
watcher.IncludeSubdirectories = false;
watcher.EnableRaisingEvents = true;
}
private void OnChanged(object sender, FileSystemEventArgs e)
{
if (e.ChangeType != WatcherChangeTypes.Changed)
{
return;
}
label1.Text = "új fájl";
}
}
}
Mi a probléma?
Mutasd a teljes hozzászólást!
Ez a téma lezárásra került a moderátor által. A lezárás oka: Témacím… témacím… témacím…