Upload files
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
.vs
|
||||
bin/
|
||||
obj/
|
||||
packages/
|
||||
*.csproj.user
|
||||
6
App.config
Normal file
6
App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
</startup>
|
||||
</configuration>
|
||||
53
DomainIpSplitter.csproj
Normal file
53
DomainIpSplitter.csproj
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{244C4952-D786-464D-9786-8964E9F40714}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>DomainIpSplitter</RootNamespace>
|
||||
<AssemblyName>DomainIpSplitter</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
25
DomainIpSplitter.sln
Normal file
25
DomainIpSplitter.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36301.6 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainIpSplitter", "DomainIpSplitter.csproj", "{244C4952-D786-464D-9786-8964E9F40714}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{244C4952-D786-464D-9786-8964E9F40714}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{244C4952-D786-464D-9786-8964E9F40714}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{244C4952-D786-464D-9786-8964E9F40714}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{244C4952-D786-464D-9786-8964E9F40714}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D55F1EBB-3BA7-4D44-9670-03EBF3478AD9}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
103
Program.cs
Normal file
103
Program.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace TextFileSplitter
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void SplitFile(string inputFile, int maxLines = 1023, string neededExt = null)
|
||||
{
|
||||
// Читаем все строки исходного файла
|
||||
string[] lines;
|
||||
try
|
||||
{
|
||||
lines = File.ReadAllLines(inputFile, Encoding.UTF8);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка при чтении файла: {ex.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Если строк меньше или равно maxLines, ничего не делаем
|
||||
if (lines.Length <= maxLines)
|
||||
{
|
||||
Console.WriteLine($"Файл содержит {lines.Length} строк (не больше {maxLines}), разделение не требуется.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Определяем базовое имя и расширение файла
|
||||
string baseName = Path.GetFileNameWithoutExtension(inputFile);
|
||||
string directory = Path.GetDirectoryName(inputFile);
|
||||
string ext = Path.GetExtension(inputFile);
|
||||
|
||||
if (!string.IsNullOrEmpty(neededExt))
|
||||
{
|
||||
ext = neededExt;
|
||||
}
|
||||
|
||||
// Если файл находится в корне диска, directory может быть null
|
||||
if (string.IsNullOrEmpty(directory))
|
||||
{
|
||||
directory = ".";
|
||||
}
|
||||
|
||||
// Разделяем файл на части
|
||||
int partNum = 1;
|
||||
for (int i = 0; i < lines.Length; i += maxLines)
|
||||
{
|
||||
// Формируем имя нового файла
|
||||
string outputFile = Path.Combine(directory, $"{baseName}_{partNum}{ext}");
|
||||
|
||||
// Определяем количество строк для текущей части
|
||||
int linesToTake = Math.Min(maxLines, lines.Length - i);
|
||||
string[] partLines = new string[linesToTake];
|
||||
Array.Copy(lines, i, partLines, 0, linesToTake);
|
||||
|
||||
// Записываем часть строк в новый файл
|
||||
try
|
||||
{
|
||||
File.WriteAllLines(outputFile, partLines, Encoding.UTF8);
|
||||
Console.WriteLine($"Создан файл {outputFile} с {partLines.Length} строками");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка при записи файла {outputFile}: {ex.Message}");
|
||||
}
|
||||
|
||||
partNum++;
|
||||
}
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.Write("Введите путь к файлу для разделения: ");
|
||||
string inputFile = Console.ReadLine();
|
||||
|
||||
if (string.IsNullOrEmpty(inputFile))
|
||||
{
|
||||
Console.WriteLine("Путь к файлу не может быть пустым.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!File.Exists(inputFile))
|
||||
{
|
||||
Console.WriteLine("Файл не существует.");
|
||||
return;
|
||||
}
|
||||
|
||||
SplitFile(inputFile, neededExt: ".bat");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Произошла ошибка: {ex.Message}");
|
||||
}
|
||||
|
||||
Console.WriteLine("Нажмите любую клавишу для выхода...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Properties/AssemblyInfo.cs
Normal file
33
Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Общие сведения об этой сборке предоставляются следующим набором
|
||||
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
|
||||
// связанные с этой сборкой.
|
||||
[assembly: AssemblyTitle("DomainIpSplitter")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DomainIpSplitter")]
|
||||
[assembly: AssemblyCopyright("Lev Rusanov © 2025")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
|
||||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
|
||||
// из модели COM задайте для атрибута ComVisible этого типа значение true.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Следующий GUID представляет идентификатор typelib, если этот проект доступен из модели COM
|
||||
[assembly: Guid("244c4952-d786-464d-9786-8964e9f40714")]
|
||||
|
||||
// Сведения о версии сборки состоят из указанных ниже четырех значений:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Номер редакции
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Reference in New Issue
Block a user