| Archiv für die Kategorie „Programmierung“ Montag, 23. Januar 2012Problem: Wenn beim öffnen eines Ordners folgende Warnung des Trojaners TR/Phorpiex 552960 bekommt: Lösung: Folgende Batch bitte auf beide USB Sticks speichern und laufen lassen. Drücke bitte die Windows Taste + R Taste und schreibe notepad in das Ausführen Fenster. Kopiere nun folgenden Text aus der Code-Box in das leere Textdokument @echo off
attrib -r -s -h *.* /d /s
del /a/f/q autorun*
rd /s /q 84612795
del %0 - Wähle Datei –> Speichern unter
- Dateiname:file.bat
- Dateityp: Wähle Alle Dateien (*.*)Es sollte nun ungefähr so aussehen
 - Starte die file.bat.
Nun sollten die Ordner wieder da sein. Am besten Daten sichern und Formatieren Schlagworte:Trojaner Veröffentlicht in Programmierung | Keine Kommentare » Mittwoch, 11. Januar 2012
Facebook Connect via Asp.net ist eigentlich sehr einfach einzurichten. Dazu benötigt ihr folgende DLL`s FacebookSDK Weiters natürlich eine Facebook App. Diese könnt ihr hier einrichten Facebook for Developer Ein kleines Beispiel: Folgender Code ist um sich einzuloggen mittels Facebook
string[] extendedPermissions = new[] { "publish_stream", "offline_access" };
var oauth = new FacebookOAuthClient { ClientId = appId };
var parameters = new Dictionary<string, object>
{
{ "response_type", "token" },
{ "display", "popup" }
};
if (extendedPermissions != null && extendedPermissions.Length > 0)
{
var scope = new StringBuilder();
scope.Append(string.Join(",", extendedPermissions));
parameters["scope"] = scope.ToString();
}
var loginUrl = oauth.GetLoginUrl(parameters);
Um nun abzuprüfen ob ein User eingeloggt ist wird folgender Code verwendet:
private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
FacebookOAuthResult result;
if (FacebookOAuthResult.TryParse(e.Url, out result))
{
if (result.IsSuccess)
{
var accesstoken = result.AccessToken;
}
else
{
var errorDescription = result.ErrorDescription;
var errorReason = result.ErrorReason;
}
}
}
Auf der FacebookSDK Seite findet ihr natürlich viele Beispiele. Viel Spaß mit Facebook und Asp.net Schlagworte:Asp.net, Connect, Facebook Veröffentlicht in Programmierung, Webprogrammierung | Keine Kommentare » Donnerstag, 14. April 2011Das FFmpeg.exe hat Problem mit Videofiles über 5-6mb Größe. Grund dafür ist, dass die FFmpeg.exe den Application pool aufhängt und seinen Ram verschlingt. Daher musste ich den Code des Prozessaufrufes umbauen. Folgender Code funktioniert auch mit Files weit über 2gb.   ProcessStartInfo oInfo = new ProcessStartInfo(this._ffExe, Parameters);
            oInfo.WorkingDirectory = Path.GetDirectoryName(this._ffExe);
            oInfo.UseShellExecute = false;
            oInfo.CreateNoWindow = true;
            oInfo.RedirectStandardOutput = true;
            oInfo.RedirectStandardError = true;
            using (Process proc = System.Diagnostics.Process.Start(oInfo)) {
                using (StreamReader srOutput = proc.StandardError) {
                    System.Text.StringBuilder output = new System.Text.StringBuilder();
                    using (StreamReader objStreamReader = proc.StandardError) {
                        System.Text.StringBuilder sbOutPut = new StringBuilder();
                        while (!proc.WaitForExit(1000)) {
                            sbOutPut.Append(objStreamReader.ReadToEnd().ToString());
                        }
                        if (proc.ExitCode == 0) {
                            proc.Close();
                            if (objStreamReader != null) {
                                objStreamReader.Close();
                            }
                        } else {
                            proc.Close();
                            if (objStreamReader != null) {
                                objStreamReader.Close();
                            }
                        }
                        return sbOutPut.ToString();
                    }
                }
            }Schlagworte:C#, ffmpeg, große dateien, Problem, prozess Veröffentlicht in Programmierung, Webprogrammierung | Keine Kommentare » Donnerstag, 14. April 2011Folgender Code beinhaltet eine Classe, welche mit Hilfe der ffmpeg.exe die VideoInformationen auslesen kann oder ein Video konvertieren kann. Code wurde hier gefunden Die ffmpeg.exe könnt ihr hier downloaden: download  public class Converter {
      #region Properties
        private string _ffExe;
        public string ffExe {
            get {
                return _ffExe;
            }
            set {
                _ffExe = value;
            }
        }
        private string _WorkingPath;
        public string WorkingPath {
            get {
                return _WorkingPath;
            }
            set {
                _WorkingPath = value;
            }
        }
        #endregion
        #region Constructors
        public Converter() {
            Initialize();
        }
        public Converter(string ffmpegExePath) {
            _ffExe = ffmpegExePath;
            Initialize();
        }
        #endregion
        #region Initialization
        private void Initialize() {
            //first make sure we have a value for the ffexe file setting
            if (string.IsNullOrEmpty(_ffExe)) {
                object o = ConfigurationManager.AppSettings["ffmpeg:ExeLocation"];
                if (o == null) {
                    throw new Exception("Could not find the location of the ffmpeg exe file.  The path for ffmpeg.exe " +
                    "can be passed in via a constructor of the ffmpeg class (this class) or by setting in the app.config or web.config file.  " +
                    "in the appsettings section, the correct property name is: ffmpeg:ExeLocation");
                } else {
                    if (string.IsNullOrEmpty(o.ToString())) {
                        throw new Exception("No value was found in the app setting for ffmpeg:ExeLocation");
                    }
                    _ffExe = o.ToString();
                }
            }
            //Now see if ffmpeg.exe exists
            string workingpath = GetWorkingFile();
            if (string.IsNullOrEmpty(workingpath)) {
                //ffmpeg doesn't exist at the location stated.
                throw new Exception("Could not find a copy of ffmpeg.exe");
            }
            _ffExe = workingpath;
            //now see if we have a temporary place to work
            if (string.IsNullOrEmpty(_WorkingPath)) {
                object o = ConfigurationManager.AppSettings["ffmpeg:WorkingPath"];
                if (o != null) {
                    _WorkingPath = o.ToString();
                } else {
                    _WorkingPath = string.Empty;
                }
            }
        }
        private string GetWorkingFile() {
            //try the stated directory
            if (File.Exists(_ffExe)) {
                return _ffExe;
            }
            //oops, that didn't work, try the base directory
            if (File.Exists(Path.GetFileName(_ffExe))) {
                return Path.GetFileName(_ffExe);
            }
            //well, now we are really unlucky, let's just return null
            return null;
        }
        #endregion
        #region Get the File without creating a file lock
        public static System.Drawing.Image LoadImageFromFile(string fileName) {
            System.Drawing.Image theImage = null;
            using (FileStream fileStream = new FileStream(fileName, FileMode.Open,
            FileAccess.Read)) {
                byte[] img;
                img = new byte[fileStream.Length];
                fileStream.Read(img, 0, img.Length);
                fileStream.Close();
                theImage = System.Drawing.Image.FromStream(new MemoryStream(img));
                img = null;
            }
            GC.Collect();
            return theImage;
        }
        public static MemoryStream LoadMemoryStreamFromFile(string fileName) {
            MemoryStream ms = null;
            using (FileStream fileStream = new FileStream(fileName, FileMode.Open,
            FileAccess.Read)) {
                byte[] fil;
                fil = new byte[fileStream.Length];
                fileStream.Read(fil, 0, fil.Length);
                fileStream.Close();
                ms = new MemoryStream(fil);
            }
            GC.Collect();
            return ms;
        }
        #endregion
        #region Run the process
        private string RunProcess(string Parameters) {
            //create a process info
            ProcessStartInfo oInfo = new ProcessStartInfo(this._ffExe, Parameters);
            oInfo.UseShellExecute = false;
            oInfo.CreateNoWindow = true;
            oInfo.RedirectStandardOutput = true;
            oInfo.RedirectStandardError = true;
            //Create the output and streamreader to get the output
            string output = null; StreamReader srOutput = null;
            //try the process
            try {
                //run the process
                Process proc = System.Diagnostics.Process.Start(oInfo);
                proc.WaitForExit();
                //get the output
                srOutput = proc.StandardError;
                //now put it in a string
                output = srOutput.ReadToEnd();
                proc.Close();
            } catch (Exception) {
                output = string.Empty;
            } finally {
                //now, if we succeded, close out the streamreader
                if (srOutput != null) {
                    srOutput.Close();
                    srOutput.Dispose();
                }
            }
            return output;
        }
        #endregion
        #region GetVideoInfo
        public VideoFile GetVideoInfo(MemoryStream inputFile, string Filename) {
            string tempfile = Path.Combine(this.WorkingPath, System.Guid.NewGuid().ToString() + Path.GetExtension(Filename));
            FileStream fs = File.Create(tempfile);
            inputFile.WriteTo(fs);
            fs.Flush();
            fs.Close();
            GC.Collect();
            VideoFile vf = null;
            try {
                vf = new VideoFile(tempfile);
            } catch (Exception ex) {
                throw ex;
            }
            GetVideoInfo(vf);
            try {
                File.Delete(tempfile);
            } catch (Exception) {
            }
            return vf;
        }
        public VideoFile GetVideoInfo(string inputPath) {
            VideoFile vf = null;
            try {
                vf = new VideoFile(inputPath);
            } catch (Exception ex) {
                throw ex;
            }
            GetVideoInfo(vf);
            return vf;
        }
        public void GetVideoInfo(VideoFile input) {
            //set up the parameters for video info
            string Params = string.Format("-i {0}", input.Path);
            string output = RunProcess(Params);
            input.RawInfo = output;
            //get duration
            Regex re = new Regex("[D|d]uration:.((\\d|:|\\.)*)");
            Match m = re.Match(input.RawInfo);
            if (m.Success) {
                string duration = m.Groups[1].Value;
                string[] timepieces = duration.Split(new char[] { ':', '.' });
                if (timepieces.Length == 4) {
                    input.Duration = new TimeSpan(0, Convert.ToInt16(timepieces[0]), Convert.ToInt16(timepieces[1]), Convert.ToInt16(timepieces[2]), Convert.ToInt16(timepieces[3]));
                }
            }
            //get audio bit rate
            re = new Regex("[B|b]itrate:.((\\d|:)*)");
            m = re.Match(input.RawInfo);
            double kb = 0.0;
            if (m.Success) {
                Double.TryParse(m.Groups[1].Value, out kb);
            }
            input.BitRate = kb;
            //get the audio format
            re = new Regex("[A|a]udio:.*");
            m = re.Match(input.RawInfo);
            if (m.Success) {
                input.AudioFormat = m.Value;
            }
            //get the video format
            re = new Regex("[V|v]ideo:.*");
            m = re.Match(input.RawInfo);
            if (m.Success) {
                input.VideoFormat = m.Value;
            }
            //get the video format
            re = new Regex("(\\d{2,3})x(\\d{2,3})");
            m = re.Match(input.RawInfo);
            if (m.Success) {
                int width = 0; int height = 0;
                int.TryParse(m.Groups[1].Value, out width);
                int.TryParse(m.Groups[2].Value, out height);
                input.Width = width;
                input.Height = height;
            }
            input.infoGathered = true;
        }
        #endregion
        #region Convert to FLV
        public OutputPackage ConvertToFLV(MemoryStream inputFile, string Filename) {
            string tempfile = Path.Combine(this.WorkingPath, System.Guid.NewGuid().ToString() + Path.GetExtension(Filename));
            FileStream fs = File.Create(tempfile);
            inputFile.WriteTo(fs);
            fs.Flush();
            fs.Close();
            GC.Collect();
            VideoFile vf = null;
            try {
                vf = new VideoFile(tempfile);
            } catch (Exception ex) {
                throw ex;
            }
            OutputPackage oo = ConvertToFLV(vf);
            try {
                File.Delete(tempfile);
            } catch (Exception) {
            }
            return oo;
        }
        public OutputPackage ConvertToFLV(string inputPath) {
            VideoFile vf = null;
            try {
                vf = new VideoFile(inputPath);
            } catch (Exception ex) {
                throw ex;
            }
            OutputPackage oo = ConvertToFLV(vf);
            return oo;
        }
        public OutputPackage ConvertToFLV(VideoFile input) {
            if (!input.infoGathered) {
                GetVideoInfo(input);
            }
            OutputPackage ou = new OutputPackage();
            //set up the parameters for getting a previewimage
            string filename = System.Guid.NewGuid().ToString() + ".jpg";
            int secs;
            //divide the duration in 3 to get a preview image in the middle of the clip
            //instead of a black image from the beginning.
            secs = (int)Math.Round(TimeSpan.FromTicks(input.Duration.Ticks / 3).TotalSeconds, 0);
            string finalpath = Path.Combine(this.WorkingPath, filename);
            string Params = string.Format("-i {0} {1} -vcodec mjpeg -ss {2} -vframes 1 -an -f rawvideo", input.Path, finalpath, secs);
            string output = RunProcess(Params);
            ou.RawOutput = output;
            if (File.Exists(finalpath)) {
                ou.PreviewImage = LoadImageFromFile(finalpath);
                try {
                    File.Delete(finalpath);
                } catch (Exception) { }
            } else { //try running again at frame 1 to get something
                Params = string.Format("-i {0} {1} -vcodec mjpeg -ss {2} -vframes 1 -an -f rawvideo", input.Path, finalpath, 1);
                output = RunProcess(Params);
                ou.RawOutput = output;
                if (File.Exists(finalpath)) {
                    ou.PreviewImage = LoadImageFromFile(finalpath);
                    try {
                        File.Delete(finalpath);
                    } catch (Exception) { }
                }
            }
            finalpath = Path.Combine(this.WorkingPath, filename);
            filename = System.Guid.NewGuid().ToString() + ".flv";
            Params = string.Format("-i {0} -y -ar 22050 -ab 64 -f flv {1}", input.Path, finalpath);
            output = RunProcess(Params);
            if (File.Exists(finalpath)) {
                ou.VideoStream = LoadMemoryStreamFromFile(finalpath);
                try {
                    File.Delete(finalpath);
                } catch (Exception) { }
            }
            return ou;
        }
        #endregion
    }
    public class VideoFile {
        #region Properties
        private string _Path;
        public string Path {
            get {
                return _Path;
            }
            set {
                _Path = value;
            }
        }
        public TimeSpan Duration { get; set; }
        public double BitRate { get; set; }
        public string AudioFormat { get; set; }
        public string VideoFormat { get; set; }
        public int Height { get; set; }
        public int Width { get; set; }
        public string RawInfo { get; set; }
        public bool infoGathered { get; set; }
        #endregion
        #region Constructors
        public VideoFile(string path) {
            _Path = path;
            Initialize();
        }
        #endregion
        #region Initialization
        private void Initialize() {
            this.infoGathered = false;
            //first make sure we have a value for the video file setting
            if (string.IsNullOrEmpty(_Path)) {
                throw new Exception("Could not find the location of the video file");
            }
            //Now see if the video file exists
            if (!File.Exists(_Path)) {
                throw new Exception("The video file " + _Path + " does not exist.");
            }
        }
        #endregion
    }
    public class OutputPackage{
        public MemoryStream VideoStream { get; set; } public System.Drawing.Image PreviewImage { get; set; } public string RawOutput { get; set; } public bool Success { get; set; }
    }
}Schlagworte:C#, ffmpeg, konvertierung, videoinfo Veröffentlicht in Programmierung, Webprogrammierung | Keine Kommentare » Dienstag, 12. April 2011Folgender Code hilft Ihnen alle Metadaten einer Datei auszulesen. Bei Videos sogar Duration/Länge und  Bitrate. Diese Funktioniert für alle Dateientypen wie z.b. txt, mp4, gif, jpg, mp3 usw.   public static class FileInfoExtensions {
        public static Dictionary<string, string> GetDetails(this FileInfo fi) {
            Dictionary<string, string> ret = new Dictionary<string, string>();
            var shl = (Shell)Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"));
            //Shell shl = new ShellClass();
            Folder folder = shl.NameSpace(fi.DirectoryName);
            FolderItem item = folder.ParseName(fi.Name);
            for (int i = 0; i < 150; i++) {
                string dtlDesc = folder.GetDetailsOf(null, i);
                string dtlVal = folder.GetDetailsOf(item, i);
                if (dtlVal == null || dtlVal == "")
                    continue;
                ret.Add(dtlDesc, dtlVal);
            }
            return ret;
        }
    }Hier muss lediglich eine Referenz zu der COM Shell32.dll hinzugefügt werden. Schlagworte:C#, Com, jpg, Metadaten, mp4, Shell32, txt Veröffentlicht in Programmierung, Webprogrammierung | Keine Kommentare » Montag, 20. September 2010Here is the code to merge a pdf file in C#. namespace MergePDF {
        public class MergeEx {
            #region Fields
            private string sourcefolder;
            private string destinationfile;
            private IList fileList = new ArrayList();
            #endregion
            #region Public Methods
            ///
            /// Add a new file, together with a given docname to
 /// the fileList and namelist collection
            ///
            ///
            public void AddFile(string pathnname) {
                fileList.Add(pathnname);
            }
            ///
            /// Generate the merged PDF
            ///
            public void Execute() {
                MergeDocs();
            }
            #endregion
            #region Private Methods
            ///
            /// Merges the Docs and renders the destinationFile
            ///
            ///
            private void MergeDocs() {
                //Step 1: Create a Docuement-Object
                Document document = new Document();
                try {
                    //Step 2: we create a writer that listens to the document
                    PdfWriter writer = PdfWriter.GetInstance(document,
new FileStream(destinationfile, FileMode.Create));
                    //Step 3: Open the document
                    document.Open();
                    PdfContentByte cb = writer.DirectContent;
                    PdfImportedPage page;
                    int n = 0;
                    int rotation = 0;
                    //Loops for each file that has been listed
                    foreach (string filename in fileList) {
                        //The current file path
                        string filePath = sourcefolder + filename;
                        // we create a reader for the document
                        PdfReader reader = new PdfReader(filePath);
                        //Gets the number of pages to process
                        n = reader.NumberOfPages;
                        int i = 0;
                        while (i < n) {
                            i++;
                            document.SetPageSize(reader.GetPageSizeWithRotation(1));
                            document.NewPage();
                            //Insert to Destination on the first page
                            if (i == 1) {
                                Chunk fileRef = new Chunk(" ");
                                fileRef.SetLocalDestination(filename);
                                document.Add(fileRef);
                            }
                            page = writer.GetImportedPage(reader, i);
                            rotation = reader.GetPageRotation(i);
                            if (rotation == 90 || rotation == 270) {
                                cb.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(i).Height);
                            } else {
                                cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
                            }
                        }
                    }
                } catch (Exception e) { throw e; } finally { document.Close(); }
            }
            #endregion
            #region Properties
            ///
            /// Gets or Sets the SourceFolder
            ///
            public string SourceFolder {
                get { return sourcefolder; }
                set { sourcefolder = value; }
            }
            ///
            /// Gets or Sets the DestinationFile
            ///
            public string DestinationFile {
                get { return destinationfile; }
                set { destinationfile = value; }
            }
            #endregion
        }
    }So you can call the merge function in the context. string sourcePath = @"D:\Pdf\";
                MergeEx objMergeEx = new MergeEx();
                objMergeEx.SourceFolder = sourcePath;
                objMergeEx.DestinationFile = sourcePath + "Mergedfile.pdf";
                objMergeEx.AddFile("parsetest.pdf");
                objMergeEx.AddFile(@"regions\" + "eisacktal.pdf");
                objMergeEx.Execute();download: itext Schlagworte:concat, Converter, itext, merge, pdf Veröffentlicht in Programmierung, Webprogrammierung | 1 Kommentar » Montag, 23. August 2010 Seit ihr auch müde vom Betriebsystem des Samsung Jets?
Warum nicht einfach das Google Android hernehmen und aufs Handy laden? Bereits seit Mai wird versucht das Android für das Samsung Jet zu optimieren. Hier eine Liste was schon optimiert wurde und was noch zu machen ist. Bereits gemacht- Booting Android 2.1
- Basic interaction with the system
Noch zu machenMany things that are not working right now are due to missing driver support from the linux kernel. Thus these features are not related to the Android system and shall not be listed here. Please see JetKernelReleases for details. - ADB / USB connection (mostly kernel related)
- Making calls / network access (GSM/3G/Wifi,…)
- Everything else that is hardware related and not yet supported by the JetKernel
- Better keymap support (work in progress)
- Proper screen resolution (work in progress)
- Touchscreen calibration (work in progress)
- ADB / USB connection (mostly kernel related)
- Use Samdroid of Cyanogen sources
- 2D/3D acceleration (This could come with Samdroid)
- Fancy stuff like live wallpapers
httpv://www.youtube.com/watch?v=GmuvT8mkq78 Die Entwickler sind schon hart am arbeiten und ich hoffe, wir können in nicht allzu ferner Zeit ein voll funktionsfähiges Jetdroid für unser Samsung Jet downloaden. Schlagworte:Android, Jetdroid, S8000, Samsung Jet Veröffentlicht in Programmierung, Technik | Keine Kommentare » Montag, 14. Juni 2010Wer die Spiele der Fußball WM miterlebt weiß, dass die nervigen Vuvuzela richtig viel Lärm machen. Warum dann nicht einfach diese nervigen Töne Filtern? Martin zeigt wies geht  Schlagworte:Filter, vuvuzela, Windows Veröffentlicht in Programmierung, Technik | Keine Kommentare » Donnerstag, 4. Februar 2010Da man beim Programmieren oft fragt ob ein String leer oder gleich null ist, habe ich ein paar String Extensions geschrieben, welche das Programmieren wesentlich vereinfachen . String Extensions: - IsEmpty
- IsNotEmpty
- FormatWith
- EqualsOneOf
- Truncate
- ToPascalCase
- ParseIntOrDefault
Ich glaube die Funktionsnamen sagen schon alles. Die Funktionen findet ihr im Anschluss (weiterlesen…) Schlagworte:C#, Extensions, IsNotEmpty, Methoden, String Veröffentlicht in Programmierung, Webprogrammierung | Keine Kommentare » |